Java Code Examples for org.apache.poi.ss.usermodel.CellStyle#setFillForegroundColor()
The following examples show how to use
org.apache.poi.ss.usermodel.CellStyle#setFillForegroundColor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExcelExportStylerColorImpl.java From autopoi with Apache License 2.0 | 8 votes |
@Override public CellStyle getHeaderStyle(short headerColor) { CellStyle titleStyle = workbook.createCellStyle(); Font font = workbook.createFont(); font.setFontHeightInPoints((short) 24); titleStyle.setFont(font); titleStyle.setFillForegroundColor(headerColor); titleStyle.setAlignment(CellStyle.ALIGN_CENTER); titleStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); return titleStyle; }
Example 2
Source File: BackgroundStyle.java From myexcel with Apache License 2.0 | 6 votes |
public static void setBackgroundColor(CellStyle style, Map<String, String> tdStyle, CustomColor customColor) { if (tdStyle == null) { return; } String color = tdStyle.get(BACKGROUND_COLOR); if (color == null) { return; } Short colorPredefined = ColorUtil.getPredefinedColorIndex(color); if (colorPredefined != null) { style.setFillForegroundColor(colorPredefined); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); return; } if (customColor.isXls()) { log.warn(".xls does not support custom colors for the time being. Please use predefined colors."); return; } int[] rgb = ColorUtil.getRGBByColor(color); setCustomColor(style, rgb, customColor); }
Example 3
Source File: ExcelExporterProcess.java From youkefu with Apache License 2.0 | 6 votes |
/** * 首列样式 * @return */ private CellStyle createFirstCellStyle(){ CellStyle cellStyle = baseCellStyle(); Font font = wb.createFont(); //font.setFontName("微软雅黑"); font.setFontHeight((short) 180); cellStyle.setFont(font); cellStyle.setWrapText(false); cellStyle.setFillForegroundColor(HSSFColor.LIGHT_GREEN.index); cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); return cellStyle; }
Example 4
Source File: XLSXWriter.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
/** * create a library of cell styles */ private static Map<String, CellStyle> createStyles(Workbook wb){ Map<String, CellStyle> styles = new HashMap<>(); CellStyle style; Font headerFont = wb.createFont(); headerFont.setBold(true); style = createBorderedStyle(wb); style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex()); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); style.setVerticalAlignment(VerticalAlignment.TOP); style.setWrapText(true); style.setFont(headerFont); styles.put("header", style); style = createBorderedStyle(wb); style.setVerticalAlignment(VerticalAlignment.TOP); style.setWrapText(true); styles.put("body", style); return styles; }
Example 5
Source File: ExcelExportStylerColorImpl.java From jeasypoi with Apache License 2.0 | 6 votes |
@Override public CellStyle stringSeptailStyle(Workbook workbook, boolean isWarp) { CellStyle style = workbook.createCellStyle(); style.setBorderLeft((short) 1); // 左边框 style.setBorderRight((short) 1); // 右边框 style.setBorderBottom((short) 1); style.setBorderTop((short) 1); style.setFillForegroundColor((short) 41); // 填充的背景颜色 style.setFillPattern(CellStyle.SOLID_FOREGROUND); // 填充图案 style.setAlignment(CellStyle.ALIGN_CENTER); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setDataFormat(STRING_FORMAT); if (isWarp) { style.setWrapText(true); } return style; }
Example 6
Source File: Ssio.java From sep4j with Apache License 2.0 | 6 votes |
private static Row createHeaders(Map<String, String> headerMap, Sheet sheet) { CellStyle style = sheet.getWorkbook().createCellStyle(); style.setFillForegroundColor(IndexedColors.YELLOW.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setBorderBottom(HSSFCellStyle.BORDER_THIN); style.setBorderTop(HSSFCellStyle.BORDER_THIN); style.setBorderRight(HSSFCellStyle.BORDER_THIN); style.setBorderLeft(HSSFCellStyle.BORDER_THIN); Row header = sheet.createRow(0); int columnIndex = 0; for (Map.Entry<String, String> entry : headerMap.entrySet()) { String headerText = StringUtils.defaultString(entry.getValue()); Cell cell = createCell(header, columnIndex); cell.setCellValue(headerText); cell.setCellStyle(style); sheet.autoSizeColumn(columnIndex); columnIndex++; } return header; }
Example 7
Source File: UKExcelUtil.java From youkefu with Apache License 2.0 | 5 votes |
/** * 首列样式 * @return */ @SuppressWarnings("deprecation") private CellStyle createFirstCellStyle(){ CellStyle cellStyle = baseCellStyle(); Font font = wb.createFont(); font.setFontHeight((short) 180); cellStyle.setFont(font); cellStyle.setFillForegroundColor(HSSFColor.LIGHT_GREEN.index); cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); return cellStyle; }
Example 8
Source File: CrosstabXLSExporter.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
public CellStyle buildDimensionCellStyle(Sheet sheet) { CellStyle cellStyle = sheet.getWorkbook().createCellStyle(); cellStyle.setAlignment(CellStyle.ALIGN_CENTER); cellStyle.setVerticalAlignment(CellStyle.ALIGN_CENTER); String headerBGColor = (String) this.getProperty(PROPERTY_DIMENSION_NAME_BACKGROUND_COLOR); logger.debug("Header background color : " + headerBGColor); short backgroundColorIndex = headerBGColor != null ? IndexedColors.valueOf(headerBGColor).getIndex() : IndexedColors.valueOf( DEFAULT_DIMENSION_NAME_BACKGROUND_COLOR).getIndex(); cellStyle.setFillForegroundColor(backgroundColorIndex); 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); String bordeBorderColor = (String) this.getProperty(PROPERTY_HEADER_BORDER_COLOR); logger.debug("Header border color : " + bordeBorderColor); short borderColorIndex = bordeBorderColor != null ? IndexedColors.valueOf(bordeBorderColor).getIndex() : IndexedColors.valueOf( DEFAULT_HEADER_BORDER_COLOR).getIndex(); cellStyle.setLeftBorderColor(borderColorIndex); cellStyle.setRightBorderColor(borderColorIndex); cellStyle.setBottomBorderColor(borderColorIndex); cellStyle.setTopBorderColor(borderColorIndex); Font font = sheet.getWorkbook().createFont(); Short headerFontSize = (Short) this.getProperty(PROPERTY_HEADER_FONT_SIZE); logger.debug("Header font size : " + headerFontSize); short headerFontSizeShort = headerFontSize != null ? headerFontSize.shortValue() : DEFAULT_HEADER_FONT_SIZE; font.setFontHeightInPoints(headerFontSizeShort); String fontName = (String) this.getProperty(PROPERTY_FONT_NAME); logger.debug("Font name : " + fontName); fontName = fontName != null ? fontName : DEFAULT_FONT_NAME; font.setFontName(fontName); String color = (String) this.getProperty(PROPERTY_DIMENSION_NAME_COLOR); logger.debug("Dimension color : " + color); short colorIndex = bordeBorderColor != null ? IndexedColors.valueOf(color).getIndex() : IndexedColors.valueOf(DEFAULT_DIMENSION_NAME_COLOR).getIndex(); font.setColor(colorIndex); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setItalic(true); cellStyle.setFont(font); return cellStyle; }
Example 9
Source File: AbstractSheet.java From tools with Apache License 2.0 | 5 votes |
public static CellStyle createHeaderStyle(Workbook wb) { CellStyle headerStyle = wb.createCellStyle(); headerStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); Font headerFont = wb.createFont(); headerFont.setFontName("Arial"); headerFont.setFontHeight(FONT_SIZE); headerFont.setBold(true); headerStyle.setFont(headerFont); headerStyle.setAlignment(HorizontalAlignment.CENTER); headerStyle.setVerticalAlignment(VerticalAlignment.CENTER); headerStyle.setWrapText(true); return headerStyle; }
Example 10
Source File: ExcelExportStylerColorImpl.java From jeasypoi with Apache License 2.0 | 5 votes |
@Override public CellStyle getTitleStyle(short color) { CellStyle titleStyle = workbook.createCellStyle(); titleStyle.setFillForegroundColor(color); // 填充的背景颜色 titleStyle.setAlignment(CellStyle.ALIGN_CENTER); titleStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); titleStyle.setFillPattern(CellStyle.SOLID_FOREGROUND); // 填充图案 titleStyle.setWrapText(true); return titleStyle; }
Example 11
Source File: ColorListener.java From hy.common.report with Apache License 2.0 | 5 votes |
/** * 对变量名称反射出来的值进行加工处理 * * @author ZhengWei(HY) * @createDate 2017-06-29 * @version v1.0 * * @param i_RTemplate 模板 * @param i_TemplateCell 模板单元格对象 * @param i_DataCell 数据单元格对象 * @param i_DataWorkbook 数据工作薄对象 * @param i_RSystemValue 系统变量信息 * @param i_Datas 本行对应的数据 * @param i_Value 反射出来的变量名称对应的值 * @return */ public String getValue(RTemplate i_RTemplate ,Cell i_TemplateCell ,Cell i_DataCell ,RWorkbook i_DataWorkbook ,RSystemValue i_RSystemValue ,Object i_Datas ,Object i_Value) { CellStyle v_NewCellStyle = null; if ( i_DataCell.getRow().getRowNum() % 2 == 1 ) { v_NewCellStyle = i_DataWorkbook.getCellStyleByCopy("奇数行" ,i_DataCell ,i_RTemplate); v_NewCellStyle.setFillForegroundColor(this.oddNumberolor); } else { v_NewCellStyle = i_DataWorkbook.getCellStyleByCopy("偶数行" ,i_DataCell ,i_RTemplate); v_NewCellStyle.setFillForegroundColor(this.evenNumberColor); } v_NewCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); Row v_Row = i_DataCell.getRow(); int v_CellCount = v_Row.getLastCellNum(); for (int i=0; i<v_CellCount; i++) { v_Row.getCell(i).setCellStyle(v_NewCellStyle); } if ( i_Value == null ) { return ""; } return i_Value.toString(); }
Example 12
Source File: StyleUtil.java From easyexcel with Apache License 2.0 | 5 votes |
/** * @param workbook * @return */ public static CellStyle buildDefaultCellStyle(Workbook workbook) { CellStyle newCellStyle = workbook.createCellStyle(); newCellStyle.setWrapText(true); newCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); newCellStyle.setAlignment(HorizontalAlignment.CENTER); newCellStyle.setLocked(true); newCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); newCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); newCellStyle.setBorderTop(BorderStyle.THIN); newCellStyle.setBorderBottom(BorderStyle.THIN); newCellStyle.setBorderLeft(BorderStyle.THIN); newCellStyle.setBorderRight(BorderStyle.THIN); return newCellStyle; }
Example 13
Source File: StyleConfiguration.java From excel-rw-annotation with Apache License 2.0 | 5 votes |
/** * 高亮样式 * @return */ public CellStyle getHighLight(HSSFColor color){ if (buildInStyleMap.containsKey(HIGHLIGHT_KEY)) { return buildInStyleMap.get(HIGHLIGHT_KEY); } CellStyle highLightStyle = workbook.createCellStyle(); highLightStyle.setFillForegroundColor(color.getIndex()); highLightStyle.setFillPattern(CellStyle.SOLID_FOREGROUND); this.setCommonStyle(highLightStyle); buildInStyleMap.put(HIGHLIGHT_KEY,highLightStyle); return highLightStyle; }
Example 14
Source File: ExcelUtil.java From RuoYi-Vue with MIT License | 5 votes |
/** * 创建表格样式 * * @param wb 工作薄对象 * @return 样式列表 */ private Map<String, CellStyle> createStyles(Workbook wb) { // 写入各条记录,每条记录对应excel表中的一行 Map<String, CellStyle> styles = new HashMap<String, CellStyle>(); CellStyle style = wb.createCellStyle(); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER); style.setBorderRight(BorderStyle.THIN); style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setBorderLeft(BorderStyle.THIN); style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setBorderTop(BorderStyle.THIN); style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setBorderBottom(BorderStyle.THIN); style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); Font dataFont = wb.createFont(); dataFont.setFontName("Arial"); dataFont.setFontHeightInPoints((short) 10); style.setFont(dataFont); styles.put("data", style); style = wb.createCellStyle(); style.cloneStyleFrom(styles.get("data")); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER); style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); Font headerFont = wb.createFont(); headerFont.setFontName("Arial"); headerFont.setFontHeightInPoints((short) 10); headerFont.setBold(true); headerFont.setColor(IndexedColors.WHITE.getIndex()); style.setFont(headerFont); styles.put("header", style); return styles; }
Example 15
Source File: ColorListener.java From hy.common.report with Apache License 2.0 | 5 votes |
/** * 对变量名称反射出来的值进行加工处理 * * @author ZhengWei(HY) * @createDate 2017-06-29 * @version v1.0 * * @param i_RTemplate 模板 * @param i_TemplateCell 模板单元格对象 * @param i_DataCell 数据单元格对象 * @param i_DataWorkbook 数据工作薄对象 * @param i_RSystemValue 系统变量信息 * @param i_Datas 本行对应的数据 * @param i_Value 反射出来的变量名称对应的值 * @return */ public String getValue(RTemplate i_RTemplate ,Cell i_TemplateCell ,Cell i_DataCell ,RWorkbook i_DataWorkbook ,RSystemValue i_RSystemValue ,Object i_Datas ,Object i_Value) { CellStyle v_NewCellStyle = null; if ( i_DataCell.getRow().getRowNum() % 2 == 1 ) { v_NewCellStyle = i_DataWorkbook.getCellStyleByCopy("单行" ,i_DataCell ,i_RTemplate); v_NewCellStyle.setFillForegroundColor(IndexedColors.ORANGE.index); } else { v_NewCellStyle = i_DataWorkbook.getCellStyleByCopy("双行" ,i_DataCell ,i_RTemplate); v_NewCellStyle.setFillForegroundColor(IndexedColors.RED.index); } v_NewCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); i_DataCell.setCellStyle(v_NewCellStyle); if ( i_Value == null ) { return ""; } return i_Value.toString(); }
Example 16
Source File: ExcelUtil.java From supplierShop with MIT License | 5 votes |
/** * 创建表格样式 * * @param wb 工作薄对象 * @return 样式列表 */ private Map<String, CellStyle> createStyles(Workbook wb) { // 写入各条记录,每条记录对应excel表中的一行 Map<String, CellStyle> styles = new HashMap<String, CellStyle>(); CellStyle style = wb.createCellStyle(); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER); style.setBorderRight(BorderStyle.THIN); style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setBorderLeft(BorderStyle.THIN); style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setBorderTop(BorderStyle.THIN); style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setBorderBottom(BorderStyle.THIN); style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); Font dataFont = wb.createFont(); dataFont.setFontName("Arial"); dataFont.setFontHeightInPoints((short) 10); style.setFont(dataFont); styles.put("data", style); style = wb.createCellStyle(); style.cloneStyleFrom(styles.get("data")); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER); style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); Font headerFont = wb.createFont(); headerFont.setFontName("Arial"); headerFont.setFontHeightInPoints((short) 10); headerFont.setBold(true); headerFont.setColor(IndexedColors.WHITE.getIndex()); style.setFont(headerFont); styles.put("header", style); return styles; }
Example 17
Source File: ForegroundColor.java From excel-io with MIT License | 4 votes |
@Override public void accept(final CellStyle style) { style.setFillForegroundColor(this.color); }
Example 18
Source File: XLSPrinter.java From unitime with Apache License 2.0 | 4 votes |
public XLSPrinter(OutputStream output, boolean checkLast) { iOutput = output; iCheckLast = checkLast; iWorkbook = new HSSFWorkbook(); iSheet = iWorkbook.createSheet(); iSheet.setDisplayGridlines(false); iSheet.setPrintGridlines(false); iSheet.setFitToPage(true); iSheet.setHorizontallyCenter(true); PrintSetup printSetup = iSheet.getPrintSetup(); printSetup.setLandscape(true); iSheet.setAutobreaks(true); printSetup.setFitHeight((short)1); printSetup.setFitWidth((short)1); iStyles = new HashMap<String, CellStyle>(); CellStyle style; style = iWorkbook.createCellStyle(); style.setBorderBottom(BorderStyle.THIN); style.setBottomBorderColor(IndexedColors.BLACK.getIndex()); style.setAlignment(HorizontalAlignment.LEFT); style.setVerticalAlignment(VerticalAlignment.TOP); style.setFont(getFont(true, false, false, Color.BLACK)); style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex()); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); style.setWrapText(true); iStyles.put("header", style); style = iWorkbook.createCellStyle(); style.setAlignment(HorizontalAlignment.LEFT); style.setVerticalAlignment(VerticalAlignment.TOP); style.setFont(getFont(false, false, false, Color.BLACK)); style.setWrapText(true); iStyles.put("plain", style); style = iWorkbook.createCellStyle(); style.setAlignment(HorizontalAlignment.RIGHT); style.setVerticalAlignment(VerticalAlignment.TOP); style.setFont(getFont(false, false, false, Color.BLACK)); iStyles.put("number", style); }
Example 19
Source File: CrosstabXLSExporter.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
public CellStyle buildHeaderCellStyle(Sheet sheet) { CellStyle cellStyle = sheet.getWorkbook().createCellStyle(); cellStyle.setAlignment(CellStyle.ALIGN_LEFT); cellStyle.setVerticalAlignment(CellStyle.ALIGN_CENTER); String headerBGColor = (String) this.getProperty(PROPERTY_HEADER_BACKGROUND_COLOR); logger.debug("Header background color : " + headerBGColor); short backgroundColorIndex = headerBGColor != null ? IndexedColors.valueOf(headerBGColor).getIndex() : IndexedColors.valueOf( DEFAULT_HEADER_BACKGROUND_COLOR).getIndex(); cellStyle.setFillForegroundColor(backgroundColorIndex); 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); String bordeBorderColor = (String) this.getProperty(PROPERTY_HEADER_BORDER_COLOR); logger.debug("Header border color : " + bordeBorderColor); short borderColorIndex = bordeBorderColor != null ? IndexedColors.valueOf(bordeBorderColor).getIndex() : IndexedColors.valueOf( DEFAULT_HEADER_BORDER_COLOR).getIndex(); cellStyle.setLeftBorderColor(borderColorIndex); cellStyle.setRightBorderColor(borderColorIndex); cellStyle.setBottomBorderColor(borderColorIndex); cellStyle.setTopBorderColor(borderColorIndex); Font font = sheet.getWorkbook().createFont(); Short headerFontSize = (Short) this.getProperty(PROPERTY_HEADER_FONT_SIZE); logger.debug("Header font size : " + headerFontSize); short headerFontSizeShort = headerFontSize != null ? headerFontSize.shortValue() : DEFAULT_HEADER_FONT_SIZE; font.setFontHeightInPoints(headerFontSizeShort); String fontName = (String) this.getProperty(PROPERTY_FONT_NAME); logger.debug("Font name : " + fontName); fontName = fontName != null ? fontName : DEFAULT_FONT_NAME; font.setFontName(fontName); String headerColor = (String) this.getProperty(PROPERTY_HEADER_COLOR); logger.debug("Header color : " + headerColor); short headerColorIndex = bordeBorderColor != null ? IndexedColors.valueOf(headerColor).getIndex() : IndexedColors.valueOf(DEFAULT_HEADER_COLOR) .getIndex(); font.setColor(headerColorIndex); font.setBoldweight(Font.BOLDWEIGHT_BOLD); cellStyle.setFont(font); return cellStyle; }
Example 20
Source File: DataSetExportServicesImpl.java From dashbuilder with Apache License 2.0 | 4 votes |
private Map<String, CellStyle> createStyles(Workbook wb){ Map<String, CellStyle> styles = new HashMap<>(); CellStyle style; Font titleFont = wb.createFont(); titleFont.setFontHeightInPoints((short)12); titleFont.setBold(true); style = wb.createCellStyle(); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER); style.setFillForegroundColor( IndexedColors.GREY_25_PERCENT.getIndex()); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); style.setFont(titleFont); style.setWrapText(false); style.setBorderBottom(BorderStyle.THIN); style.setBottomBorderColor(IndexedColors.GREY_80_PERCENT.getIndex()); styles.put("header", style); Font cellFont = wb.createFont(); cellFont.setFontHeightInPoints((short)10); cellFont.setBold(true); style = wb.createCellStyle(); style.setAlignment(HorizontalAlignment.RIGHT); style.setVerticalAlignment(VerticalAlignment.BOTTOM); style.setFont(cellFont); style.setWrapText(false); style.setDataFormat(wb.createDataFormat().getFormat( BuiltinFormats.getBuiltinFormat( 3 ))); styles.put("integer_number_cell", style); style = wb.createCellStyle(); style.setAlignment(HorizontalAlignment.RIGHT); style.setVerticalAlignment(VerticalAlignment.BOTTOM); style.setFont(cellFont); style.setWrapText(false); style.setDataFormat(wb.createDataFormat().getFormat(BuiltinFormats.getBuiltinFormat(4))); styles.put("decimal_number_cell", style); style = wb.createCellStyle(); style.setAlignment(HorizontalAlignment.LEFT); style.setVerticalAlignment(VerticalAlignment.BOTTOM); style.setFont(cellFont); style.setWrapText(false); style.setDataFormat( (short) BuiltinFormats.getBuiltinFormat("text") ); styles.put(TEXT_CELL, style); style = wb.createCellStyle(); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.BOTTOM); style.setFont(cellFont); style.setWrapText(false); style.setDataFormat(wb.createDataFormat().getFormat( DateFormatConverter.convert( Locale.getDefault(), dateFormatPattern ))); styles.put("date_cell", style); return styles; }