Java 颜色未设置为工作簿
我正在使用java工作簿xls,但无法设置颜色Java 颜色未设置为工作簿,java,excel,apache-poi,Java,Excel,Apache Poi,我正在使用java工作簿xls,但无法设置颜色 CellStyle cellStyle = sheet.getWorkbook().createCellStyle(); cellStyle.setFillBackgroundColor(HSSFColor.DARK_RED.index); Cell celli = row0.createCell((short) i); celli.setCellValue(list.get(i).toString()); celli.setCellStyle(
CellStyle cellStyle = sheet.getWorkbook().createCellStyle();
cellStyle.setFillBackgroundColor(HSSFColor.DARK_RED.index);
Cell celli = row0.createCell((short) i);
celli.setCellValue(list.get(i).toString());
celli.setCellStyle(cellStyle);
我正在使用cellstyle,但没有设置颜色。您应该使用
cellStyle.setFillForegroundColor(HSSFColor.DARK_RED.index);
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
而不是
cellStyle.setFillBackgroundColor(HSSFColor.DARK_RED.index);
你应该使用
cellStyle.setFillForegroundColor(HSSFColor.DARK_RED.index);
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
而不是
cellStyle.setFillBackgroundColor(HSSFColor.DARK_RED.index);