List of usage examples for org.apache.poi.ss.util CellUtil FILL_PATTERN
String FILL_PATTERN
To view the source code for org.apache.poi.ss.util CellUtil FILL_PATTERN.
Click Source Link
From source file:bs.global.util.ExcelFactory.java
private void writeCell(HSSFRow row, int col, Object value, FormatType formatType, Short bgColor, HSSFFont font) throws NestableException { HSSFCell cell = HSSFCellUtil.createCell(row, col, null); if (value == null) { return;/* ww w. j a v a2 s . c o m*/ } if (font != null) { HSSFCellStyle style = workbook.createCellStyle(); style.setFont(font); cell.setCellStyle(style); } switch (formatType) { case TEXT: cell.setCellValue(value.toString()); break; case INTEGER: cell.setCellValue(((Number) value).intValue()); HSSFCellUtil.setCellStyleProperty(cell, workbook, CellUtil.DATA_FORMAT, HSSFDataFormat.getBuiltinFormat(("#,##0"))); break; case FLOAT: cell.setCellValue(((Number) value).doubleValue()); HSSFCellUtil.setCellStyleProperty(cell, workbook, CellUtil.DATA_FORMAT, HSSFDataFormat.getBuiltinFormat(("#,##0.00"))); break; case DATE: cell.setCellValue((Date) value); HSSFCellUtil.setCellStyleProperty(cell, workbook, CellUtil.DATA_FORMAT, HSSFDataFormat.getBuiltinFormat(("m/d/yy"))); break; case MONEY: cell.setCellValue(((Number) value).intValue()); HSSFCellUtil.setCellStyleProperty(cell, workbook, CellUtil.DATA_FORMAT, format.getFormat("($#,##0.00);($#,##0.00)")); break; case PERCENTAGE: cell.setCellValue(((Number) value).doubleValue()); HSSFCellUtil.setCellStyleProperty(cell, workbook, CellUtil.DATA_FORMAT, HSSFDataFormat.getBuiltinFormat("0.00%")); } if (bgColor != null) { HSSFCellUtil.setCellStyleProperty(cell, workbook, CellUtil.FILL_FOREGROUND_COLOR, bgColor); HSSFCellUtil.setCellStyleProperty(cell, workbook, CellUtil.FILL_PATTERN, HSSFCellStyle.SOLID_FOREGROUND); } }
From source file:org.haplo.jsinterface.generate.KGenerateXLS.java
License:Mozilla Public License
private void styleFill(SheetStyleInstruction i) { HashMap<String, Object> properties = new HashMap<String, Object>(2); properties.put(CellUtil.FILL_PATTERN, FillPatternType.SOLID_FOREGROUND); properties.put(CellUtil.FILL_FOREGROUND_COLOR, new Short(styleFindColour(IndexedColors.GREY_25_PERCENT.getIndex(), i.colour))); styleApplyToRegion(i, properties);// w ww . ja va 2 s.co m }