Closed brged closed 3 weeks ago
3.2.1
afterCellDispose(CellWriteHandlerContext context) 方法中改变样式,setCellStyle中看到writeCellStyle和originCellStyle
WriteCellData<?> firstCellData = context.getFirstCellData(); WriteCellStyle defaultWriteCellStyle = firstCellData.getWriteCellStyle(); // 重置样式 firstCellData.setWriteCellStyle(new WriteCellStyle()); firstCellData.setOriginCellStyle(workbook.createCellStyle()); // 给writeCellStyle设置背景色和字体 firstCellData.getWriteCellStyle().setFillPatternType(FillPatternType.SOLID_FOREGROUND); firstCellData.getWriteCellStyle().setFillBackgroundColor(IndexedColors.RED.getIndex()); //红 WriteFont writeFont = new WriteFont(); writeFont.setColor(IndexedColors.RED.getIndex()); // 红 firstCellData.getWriteCellStyle().setWriteFont(writeFont); // 给originCellStyle设置背景色和字体 firstCellData.setOriginCellStyle(workbook.createCellStyle()); firstCellData.getOriginCellStyle().setFillPattern(FillPatternType.SOLID_FOREGROUND); firstCellData.getOriginCellStyle().setFillForegroundColor(IndexedColors.BLUE.getIndex()); // 蓝 Font font = workbook.createFont(); font.setColor(IndexedColors.BLUE.getIndex()); firstCellData.getOriginCellStyle().setFont(font); // 蓝
输出样式是蓝底红字
然后看 WriteWorkbookHolder.createCellStyle(WriteCellStyle writeCellStyle, CellStyle originCellStyle) 方法中 样式生效顺序是 writeCellStyle, originCellStyle 字体生效顺序是 originFont, writeFont 内容格式化是最终样式的格式化
用4.0.2测试没问题的,优先级writeStyle > orginStyle,context.getCell().getCellStyle()的设置无效
版本
3.2.1
触发场景描述
afterCellDispose(CellWriteHandlerContext context) 方法中改变样式,setCellStyle中看到writeCellStyle和originCellStyle
触发Bug的代码
提示的异常或者没有达到的效果
输出样式是蓝底红字
然后看 WriteWorkbookHolder.createCellStyle(WriteCellStyle writeCellStyle, CellStyle originCellStyle) 方法中 样式生效顺序是 writeCellStyle, originCellStyle 字体生效顺序是 originFont, writeFont 内容格式化是最终样式的格式化