Examples of CellStyle


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

                    }
                    if (type == Cell.CELL_TYPE_STRING) {
                        xhtml.characters(cell.getRichStringCellValue()
                                .getString());
                    } else if (type == Cell.CELL_TYPE_NUMERIC) {
                      CellStyle style = cell.getCellStyle();
                      xhtml.characters(
                        formatter.formatRawCellContents(cell.getNumericCellValue(),
                              style.getDataFormat(),
                              style.getDataFormatString()));
                    } else {
                        XSSFCell xc = (XSSFCell) cell;
                        String rawValue = xc.getRawValue();
                        if (rawValue != null) {
                            xhtml.characters(rawValue);
View Full Code Here

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

    for(int rowIndex = startRowIndex; rowIndex <= endRowIndex; rowIndex++){     
      Row row = sheet.getRow(rowIndex);
      if(row == null) row = sheet.createRow(rowIndex);
      for(int c = startColIndex; c <= endColIndex; c ++){
        String cIdx = ExcelUtil.offsetCellIndex(cellIndex, rowIndex-startRowIndex, c - startColIndex);
        CellStyle style = styleMap.get(cIdx);
        if(style == null) continue;
        Cell cell = row.getCell(c);
        if(cell == null) cell = row.createCell(c)
        cell.setCellStyle(style);
      }
View Full Code Here

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

    if(cell.getCellStyle() == null || (cell.getCellType() != Cell.CELL_TYPE_NUMERIC)
        || (!DateUtil.isCellDateFormatted(cell))
        || DateUtil.isADateFormat(style.getDataFormat(), style.getDataFormatString()))
      cell.setCellStyle(style);
    else{     
      CellStyle cstyle = sheet.getWorkbook().createCellStyle();
      cstyle.cloneStyleFrom(style);
      cstyle.setDataFormat(cell.getCellStyle().getDataFormat());
      cell.setCellStyle(cstyle);
    }
  }
View Full Code Here

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

    if(value instanceof Date) {
      //if current cell do not formatted as date, set is as one date     
      if(cell.getCellType() != Cell.CELL_TYPE_NUMERIC)
        cell.setCellType(Cell.CELL_TYPE_NUMERIC);
      if(!DateUtil.isCellDateFormatted(cell)){
        CellStyle style = cell.getSheet().getWorkbook().createCellStyle();
        if(cell.getCellStyle() == null){
          style.cloneStyleFrom(cell.getCellStyle());
        }
        style.setDataFormat(
            cell.getSheet().getWorkbook().getCreationHelper().createDataFormat()
              .getFormat(LoxiaSupportSettings.getInstance().
                  get(LoxiaSupportConstants.DATE_PATTERN))
            );
        cell.setCellStyle(style);
View Full Code Here

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

            continue;
          }

          // A empty cell with a defined background ..
          final Cell cell = getCellAt(col, row);
          final CellStyle style =
              getCellStyleProducer().createCellStyle(null, null, background);
          if (style != null)
          {
            cell.setCellStyle(style);
          }
          continue;
        }

        if (content.isCommited() == false)
        {
          throw new InvalidReportStateException("Uncommited content encountered");
        }

        final long contentOffset = contentProducer.getContentOffset(row, col);
        final TableRectangle rectangle = sheetLayout.getTableBounds
            (content.getX(), content.getY() + contentOffset,
                content.getWidth(), content.getHeight(), null);
        if (rectangle.isOrigin(col, row) == false)
        {
          // A spanned cell ..
          continue;
        }

        final CellBackground fastBackground = cellBackgroundProducer.getBackgroundForBox
            (logicalPage, sheetLayout, rectangle.getX1(), rectangle.getY1(),
                rectangle.getColumnSpan(), rectangle.getRowSpan(), false, sectionType, content);
        // export the cell and all content ..

        final Cell cell = getCellAt(col, row);
        final CellStyle style =
            getCellStyleProducer().createCellStyle(content.getInstanceId(), content.getStyleSheet(), fastBackground);
        if (style != null)
        {
          cell.setCellStyle(style);
        }
View Full Code Here

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

      {
        final CellMarker.SectionType sectionType = contentProducer.getSectionType(row, col);
        final CellBackground bg = cellBackgroundProducer.getBackgroundForBox
            (logicalPage, sheetLayout, rectX + spannedCol, rectY + spannedRow, 1, 1, false, sectionType, content);
        final Cell regionCell = getCellAt((col + spannedCol), row + spannedRow);
        final CellStyle spannedStyle =
            getCellStyleProducer().createCellStyle(content.getInstanceId(), content.getStyleSheet(), bg);
        if (spannedStyle != null)
        {
          regionCell.setCellStyle(spannedStyle);
        }
View Full Code Here

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

    {
      // Read in the styles ...
      final short predefinedStyles = workbook.getNumCellStyles();
      for (short i = 0; i < predefinedStyles; i++)
      {
        final CellStyle cellStyleAt = workbook.getCellStyleAt(i);
        this.styleCache.put(new HSSFCellStyleKey(cellStyleAt), cellStyleAt);
      }
    }
  }
View Full Code Here

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

            "HSSFCellStyleProducer will not create more styles. New cells will not have any style.");
        return null;
      }
    }

    final CellStyle hssfCellStyle = workbook.createCellStyle();
    if (element != null)
    {
      hssfCellStyle.setAlignment(styleKey.getHorizontalAlignment());
      hssfCellStyle.setVerticalAlignment(styleKey.getVerticalAlignment());
      hssfCellStyle.setFont(workbook.getFontAt(styleKey.getFont()));
      hssfCellStyle.setWrapText(styleKey.isWrapText());
      if (styleKey.getDataStyle() >= 0)
      {
        hssfCellStyle.setDataFormat(styleKey.getDataStyle());
      }
    }
    if (bg != null)
    {
      if (hssfCellStyle instanceof XSSFCellStyle)
      {
        final XSSFCellStyle xssfCellStyle = (XSSFCellStyle) hssfCellStyle;
        if (BorderStyle.NONE.equals(bg.getBottom().getBorderStyle()) == false)
        {
          hssfCellStyle.setBorderBottom(styleKey.getBorderStrokeBottom());
          xssfCellStyle.setBorderColor(XSSFCellBorder.BorderSide.BOTTOM,
              createXSSFColor(styleKey.getExtendedColorBottom()));
        }
        if (BorderStyle.NONE.equals(bg.getTop().getBorderStyle()) == false)
        {
          hssfCellStyle.setBorderTop(styleKey.getBorderStrokeTop());
          xssfCellStyle.setBorderColor(XSSFCellBorder.BorderSide.TOP,
              createXSSFColor(styleKey.getExtendedColorTop()));
        }
        if (BorderStyle.NONE.equals(bg.getLeft().getBorderStyle()) == false)
        {
          hssfCellStyle.setBorderLeft(styleKey.getBorderStrokeLeft());
          xssfCellStyle.setBorderColor(XSSFCellBorder.BorderSide.LEFT,
              createXSSFColor(styleKey.getExtendedColorLeft()));
        }
        if (BorderStyle.NONE.equals(bg.getRight().getBorderStyle()) == false)
        {
          hssfCellStyle.setBorderRight(styleKey.getBorderStrokeRight());
          xssfCellStyle.setBorderColor(XSSFCellBorder.BorderSide.RIGHT,
              createXSSFColor(styleKey.getExtendedColorRight()));
        }
        if (bg.getBackgroundColor() != null)
        {
          xssfCellStyle.setFillForegroundColor(createXSSFColor(styleKey.getExtendedColor()));
          hssfCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
        }
      }
      else
      {
        if (BorderStyle.NONE.equals(bg.getBottom().getBorderStyle()) == false)
        {
          hssfCellStyle.setBorderBottom(styleKey.getBorderStrokeBottom());
          hssfCellStyle.setBottomBorderColor(styleKey.getColorBottom());
        }
        if (BorderStyle.NONE.equals(bg.getTop().getBorderStyle()) == false)
        {
          hssfCellStyle.setBorderTop(styleKey.getBorderStrokeTop());
          hssfCellStyle.setTopBorderColor(styleKey.getColorTop());
        }
        if (BorderStyle.NONE.equals(bg.getLeft().getBorderStyle()) == false)
        {
          hssfCellStyle.setBorderLeft(styleKey.getBorderStrokeLeft());
          hssfCellStyle.setLeftBorderColor(styleKey.getColorLeft());
        }
        if (BorderStyle.NONE.equals(bg.getRight().getBorderStyle()) == false)
        {
          hssfCellStyle.setBorderRight(styleKey.getBorderStrokeRight());
          hssfCellStyle.setRightBorderColor(styleKey.getColorRight());
        }
        if (bg.getBackgroundColor() != null)
        {
          hssfCellStyle.setFillForegroundColor(styleKey.getColor());
          hssfCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
        }
      }
    }

View Full Code Here

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

    for (final CellLayoutInfo layoutInfo : backgroundCells)
    {
      int col = layoutInfo.getX1();
      int row = layoutInfo.getY1();
      final Cell cell = getCellAt(col, row);
      final CellStyle style = getCellStyleProducer().createCellStyle(null, null, layoutInfo.getBackground());
      if (style != null)
      {
        cell.setCellStyle(style);
      }
View Full Code Here

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

    rect.setRect(tableRectangle.getX1(), tableRectangle.getY1() + rowOffset,
        tableRectangle.getX2(), tableRectangle.getY2() + rowOffset);

    Cell cellAt = getCellAt(rect.getX1(), rect.getY1());
    CellBackground bg = tableRectangle.getBackground();
    CellStyle cellStyle = getCellStyleProducer().createCellStyle(element.getObjectID(), element.getComputedStyle(), bg);
    if (cellStyle != null)
    {
      cellAt.setCellStyle(cellStyle);
    }
    if (applyCellValue(element, cellAt, rect, runtime))
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.