We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
快速开始 、常见问题
使用excel模版导出,需要使用拦截器afterCellDispose,根据业务逻辑判定,对指定的cell修改。最终需要修改的样式对全局cell生效。
public class MyCellWriterHandler implements CellWriteHandler { @Override public void afterCellDispose(CellWriteHandlerContext context) { Cell cell = context.getCell(); CellStyle cellStyle = cell.getCellStyle(); if (cellStyle == null) { cellStyle = cell.getSheet().getWorkbook().createCellStyle(); // 创建新的样式 } String sheetName = cell.getRow().getSheet().getSheetName(); // 这里的代码已经简化了,就是对指定sheet页的指定单元格上背景色 if (sheetName.equals("基础信息") && cell.getColumnIndex() == 0) { cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); } cell.setCellStyle(cellStyle); } }
这是我的写入代码:
public void write(ExcelWriter writer, W data) { init(); for (Map.Entry<String, ExcelSheetAdapter<?>> entry : excelSheetMetaDataMap.entrySet()) { String sheetName = entry.getKey(); WriteSheet writeSheet = EasyExcel.writerSheet(sheetName) .needHead(true) .registerWriteHandler(new MyCellWriterHandler()) .build(); writer.write(getData(data, classExcelSheetAdapterMap.getKey(entry.getValue())), writeSheet); } writer.finish(); }
所有的单元格都被渲染了灰色背景色
EXPORT_OFFERING_INSTANCE20241117021055_2471.xlsx
The text was updated successfully, but these errors were encountered:
zhuangjiaju
No branches or pull requests
建议先去看文档
快速开始 、常见问题
触发场景描述
使用excel模版导出,需要使用拦截器afterCellDispose,根据业务逻辑判定,对指定的cell修改。最终需要修改的样式对全局cell生效。
触发Bug的代码
这是我的写入代码:
提示的异常或者没有达到的效果
所有的单元格都被渲染了灰色背景色
EXPORT_OFFERING_INSTANCE20241117021055_2471.xlsx
The text was updated successfully, but these errors were encountered: