use*_*599 0 java apache excel apache-poi
试图写入工作簿并使用...更改单元格颜色
CellStyle style = wb.createCellStyle();
style.setFillBackgroundColor(IndexedColors.BLUE.getIndex());
style.setFillPattern(CellStyle.ALIGN_FILL);
for (int i = 0; i < headerTitles.length; i++) {
Cell cell = headerRow.createCell(i);
cell.setCellValue(headerTitles[i]);
cell.setCellStyle(style);
}
Run Code Online (Sandbox Code Playgroud)
然而它似乎输出的颜色只有灰色点的前景,我似乎无法找出原因.
其次,自动设置单元格宽度的方法是什么,甚至是工作簿的前5列.
问候
对于第二个问题,请使用此方法:
void org.apache.poi.hssf.usermodel.HSSFSheet.autoSizeColumn(int column)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5413 次 |
最近记录: |