流写出设置
ExcelWriter writer = ExcelUtil.getWriter();
// ...
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
response.setHeader("Content-Disposition","attachment;filename="
+ DateUtil.formatDate(new Date()) + ".xlsx");
OutputStream out = response.getOutputStream();
writer.flush(out, true);
writer.close();
IoUtil.close(out);
写出数据到单元格
writer.writeCellValue(0, 0, row);
设置全局单元格样式
ExcelWriter writer = ExcelUtil.getWriter();
CellStyle cellStyle = writer.getCellStyle();
cellStyle.setBorderBottom(BorderStyle.NONE); // 无边框
设置单个单元格样式
CellStyle style = writer.createCellStyle(x, y);
style.setFillForegroundColor(IndexedColors.CORAL.getIndex()); // 背景色
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
style.setAlignment(HorizontalAlignment.CENTER); // 水平对齐
style.setVerticalAlignment(VerticalAlignment.CENTER); // 垂直对齐