我已经使用Apache POI为excel编写了颜色格式代码 . 在MS Excel 2010中,颜色和字体的格式很好 . 但是它与excel 2003没有兼容性 . 当在MS Excel 2003中打开文件时格式化不存在 .
这里是示例代码:
CellStyle style = getWorkbook().createCellStyle();
Font font = wb.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short)11);
style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
Cell cell = excelRow.createCell(10);
cell.setCellStyle(style);
如果有任何建议,请告诉我 .
1 回答
我也面临同样的问题 . 这与excel版本无关 . 我们必须在循环之前创建样式,并在创建后将样式应用于特定单元格 .
[https://stackoverflow.com/a/11792648/1211000(it](https://stackoverflow.com/a/11792648/1211000(it)可能有帮助)