Package org.apache.poi.ss.usermodel

Examples of org.apache.poi.ss.usermodel.CellStyle


                value = null;
              }
            }
            else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC)
            {
              final CellStyle hssfCellStyle = cell.getCellStyle();
              if (isDateFormat(hssfCellStyle.getDataFormat(), hssfCellStyle.getDataFormatString()))
              {
                value = cell.getDateCellValue();
              }
              else
              {
View Full Code Here


   *@param propertyValue The value of the property that is to be changed.
   *@param cell The cell that needs it's style changes
   */
  public static void setCellStyleProperty(Cell cell, Workbook workbook, String propertyName,
      Object propertyValue) {
    CellStyle originalStyle = cell.getCellStyle();
    CellStyle newStyle = null;
    Map<String, Object> values = getFormatProperties(originalStyle);
    values.put(propertyName, propertyValue);

    // index seems like what index the cellstyle is in the list of styles for a workbook.
    // not good to compare on!
    short numberCellStyles = workbook.getNumCellStyles();

    for (short i = 0; i < numberCellStyles; i++) {
      CellStyle wbStyle = workbook.getCellStyleAt(i);
      Map<String, Object> wbStyleMap = getFormatProperties(wbStyle);

      if (wbStyleMap.equals(values)) {
        newStyle = wbStyle;
        break;
View Full Code Here

            _rowContainedNullCells = true;
            return;
        }
        String ref = new CellReference(_rownum, columnIndex).formatAsString();
        _out.write("<c r=\"" + ref + "\"");
        CellStyle cellStyle = cell.getCellStyle();
        if (cellStyle.getIndex() != 0) _out.write(" s=\"" + cellStyle.getIndex() + "\"");
        int cellType = cell.getCellType();
        switch (cellType) {
            case Cell.CELL_TYPE_BLANK: {
                _out.write(">");
                break;
View Full Code Here

            _rowContainedNullCells = true;
            return;
        }
        String ref = new CellReference(_rownum, columnIndex).formatAsString();
        _out.write("<c r=\"" + ref + "\"");
        CellStyle cellStyle = cell.getCellStyle();
        if (cellStyle.getIndex() != 0) _out.write(" s=\"" + cellStyle.getIndex() + "\"");
        int cellType = cell.getCellType();
        switch (cellType) {
            case Cell.CELL_TYPE_BLANK: {
                _out.write(">");
                break;
View Full Code Here

        if (type == Cell.CELL_TYPE_FORMULA) {
            type = cell.getCachedFormulaResultType();
        }

        if (type == Cell.CELL_TYPE_NUMERIC) {
            CellStyle cs = cell.getCellStyle();

            if (cs.getDataFormatString() != null) {
                text.append(formatter.formatRawCellContents(
                        cell.getNumericCellValue(), cs.getDataFormat(), cs.getDataFormatString()
                        ));
                return;
            }
        }
View Full Code Here

      sheet.createRow(i);
    }
  }

  private int buildDataMatrix(Sheet sheet, JSONArray data, int rowOffset, int columnOffset, CreationHelper createHelper) throws JSONException {
    CellStyle cellStyle = buildDataCellStyle(sheet);
    CellStyle sumCellStyle = buildDataCellStyle(sheet);
    sumCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
   
    int endRowNum = 0;
    for (int i = 0; i < data.length(); i++) {
      JSONArray array = (JSONArray) data.get(i);
      for (int j = 0; j < array.length(); j++) {
View Full Code Here

   * @throws JSONException
   */
  private void buildRowsHeaders(Sheet sheet, JSONArray siblings, int rowNum, int columnNum, CreationHelper createHelper) throws JSONException {
    int rowsCounter = rowNum;
   
    CellStyle cellStyle = buildHeaderCellStyle(sheet);
       
    for (int i = 0; i < siblings.length(); i++) {
      JSONObject aNode = (JSONObject) siblings.get(i);
      Row row = sheet.getRow(rowsCounter);
      Cell cell = row.createCell(columnNum);
View Full Code Here

   
  }


  public CellStyle buildHeaderCellStyle(Sheet sheet){
    CellStyle cellStyle = sheet.getWorkbook().createCellStyle();
        cellStyle.setAlignment(CellStyle.ALIGN_LEFT);
        cellStyle.setVerticalAlignment(CellStyle.ALIGN_CENTER)
        cellStyle.setFillForegroundColor(IndexedColors.AQUA.getIndex());
        cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
        cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
        cellStyle.setBorderLeft(CellStyle.BORDER_THIN);
        cellStyle.setBorderRight(CellStyle.BORDER_THIN);
        cellStyle.setBorderTop(CellStyle.BORDER_THIN);
        cellStyle.setLeftBorderColor(IndexedColors.DARK_BLUE.getIndex());
        cellStyle.setRightBorderColor(IndexedColors.DARK_BLUE.getIndex());
        cellStyle.setBottomBorderColor(IndexedColors.DARK_BLUE.getIndex());
        cellStyle.setTopBorderColor(IndexedColors.DARK_BLUE.getIndex());
        Font font = sheet.getWorkbook().createFont();
        font.setFontHeightInPoints((short)14);
        font.setFontName("Arial");
        font.setColor(IndexedColors.DARK_BLUE.getIndex());
        font.setBoldweight(Font.BOLDWEIGHT_BOLD);
        cellStyle.setFont(font);
        return cellStyle;
  }
View Full Code Here

        cellStyle.setFont(font);
        return cellStyle;
  }
 
  public CellStyle buildDataCellStyle(Sheet sheet){
    CellStyle cellStyle = sheet.getWorkbook().createCellStyle();
        cellStyle.setAlignment(CellStyle.ALIGN_RIGHT);
        cellStyle.setVerticalAlignment(CellStyle.ALIGN_CENTER);
        cellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());
        cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);   
        cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
        cellStyle.setBorderLeft(CellStyle.BORDER_THIN);
        cellStyle.setBorderRight(CellStyle.BORDER_THIN);
        cellStyle.setBorderTop(CellStyle.BORDER_THIN);
        cellStyle.setLeftBorderColor(IndexedColors.BLUE.getIndex());
        cellStyle.setRightBorderColor(IndexedColors.BLUE.getIndex());
        cellStyle.setBottomBorderColor(IndexedColors.BLUE.getIndex());
        cellStyle.setTopBorderColor(IndexedColors.BLUE.getIndex());
        Font font = sheet.getWorkbook().createFont();
        font.setFontHeightInPoints((short)12);
        font.setFontName("Arial");
        font.setColor(IndexedColors.BLACK.getIndex());
        cellStyle.setFont(font);
        return cellStyle;
  }
View Full Code Here

   * @param createHelper The file creation helper
   * @throws JSONException
   */
  private void buildColumnsHeader(Sheet sheet, JSONArray siblings, int rowNum, int columnNum, CreationHelper createHelper) throws JSONException {
    int columnCounter = columnNum;
    CellStyle cellStyle = buildHeaderCellStyle(sheet);
    for (int i = 0; i < siblings.length(); i++) {
      JSONObject aNode = (JSONObject) siblings.get(i);
      Row row = sheet.getRow(rowNum);
      Cell cell = row.createCell(columnCounter);
      String text = (String) aNode.get(CrossTab.CROSSTAB_NODE_JSON_KEY);
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.usermodel.CellStyle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.