use of com.diboot.file.excel.annotation.ExcelComment in project diboot by dibo-software.
the class CommentWriteHandler method afterCellCreate.
/**
* 头部批注处理
*/
@Override
public void afterCellCreate(CellWriteHandlerContext context) {
Head head = context.getHeadData();
List<String> headNames = head.getHeadNameList();
int lastHeadIndex = headNames.size() - 1;
Integer rowIndex = context.getRowIndex();
if (!context.getHead() || rowIndex != lastHeadIndex && !headNames.get(rowIndex).equals(headNames.get(lastHeadIndex))) {
return;
}
ExcelComment comment = AnnotationUtils.getAnnotation(head.getField(), ExcelComment.class);
// 空批注不写入
if (comment == null || V.isEmpty(comment.value())) {
return;
}
Sheet sheet = context.getWriteSheetHolder().getSheet();
Cell cell = context.getCell();
cell.setCellComment(buildComment(sheet.createDrawingPatriarch(), cell.getColumnIndex(), sheet.getLastRowNum(), comment.value()));
}
Aggregations