use of com.diboot.file.excel.BaseExcelModel in project diboot by dibo-software.
the class CommentWriteHandler method afterCellDispose.
/**
* 数据批注处理
* <p>
* 包含回写异常数据
*/
@Override
public void afterCellDispose(CellWriteHandlerContext context) {
int dataIndex = context.getRelativeRowIndex();
if (context.getHead() || V.isEmpty(dataList) || dataList.size() <= dataIndex) {
return;
}
BaseExcelModel excelModel = dataList.get(dataIndex);
String fieldName = context.getHeadData().getFieldName();
Cell cell = context.getCell();
// 批注写入
String comment = S.join(excelModel.getComment().get(fieldName), ";\n");
if (V.notEmpty(comment)) {
Sheet sheet = context.getWriteSheetHolder().getSheet();
cell.setCellComment(buildComment(sheet.createDrawingPatriarch(), cell.getColumnIndex(), sheet.getLastRowNum(), comment));
}
// 回写无效值
Map<String, String> field2InvalidValueMap = excelModel.getField2InvalidValueMap();
if (field2InvalidValueMap.containsKey(fieldName)) {
cell.setCellValue(field2InvalidValueMap.get(fieldName));
}
}
Aggregations