POI 设置单元格背景颜色【区分格式 xls、xlsx】
其他
2018-09-30 04:09:12
阅读次数: 0
XLS 设置单元格填充颜色 Workbook workBook = new XSSFWorkbook();
Sheet sheet = workBook.createSheet("商品信息表");
Row row1 = sheet.createRow(0);
CellStyle headStyle = workBook.createCellStyle();
headStyle.setFillPattern(HSSFCellStyle.FINE_DOTS );
headStyle.setFillBackgroundColor(HSSFColor.RED().getIndex()); for(int i=0;i<6;i++)
{
row1.getCell(i).setCellStyle(headStyle);
} |
XLSX 的单元格填充颜色 Workbook workBook = new XSSFWorkbook();
Sheet sheet = workBook.createSheet("商品信息表");
Row row1 = sheet.createRow(0);
CellStyle headStyle = workBook.createCellStyle();
headStyle.setFillPattern(CellStyle.FINE_DOTS);
headStyle.setFillBackgroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex());
for(int i=0;i<6;i++)
{
row1.getCell(i).setCellStyle(headStyle);
} |
转载自blog.csdn.net/hexiaoli666/article/details/80988715