public static void main(String[] args) throws Exception {
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet();
int k = 1;
for (int i = 0; i < 40; i++) {
Row row = sheet.createRow(i);
for (int j = 0; j < 4; j++) {
CellStyle style = wb.createCellStyle();
style.setFillForegroundColor((short)(k));
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
Cell cell = row.createCell(j);
cell.setCellValue(k);
cell.setCellStyle(style);
k++;
}
}
// 写入文件
FileOutputStream out = new FileOutputStream("dome.xlsx");
wb.write(out);
}
java生成excel文件 背景颜色对照表
最新推荐文章于 2023-02-01 17:35:20 发布