POI 导出模板的批注显示错误

POI 导出模板的批注显示错误

场景

当吾辈想要手动设置批注大小时出现的问题,错误效果如下

clipboard.png

错误代码

final CreationHelper factory = this.workbook.getCreationHelper();
final ClientAnchor anchor = factory.createClientAnchor();
anchor.setCol1(tempCol.get());
anchor.setCol1(tempCol.get() + 3);
anchor.setRow1(finalStartRow);
anchor.setRow1(finalStartRow + 3);
final Comment comment = drawing.createCellComment(anchor);
comment.setString(this.excelType == ExcelType.XLSX ? new XSSFRichTextString(prompt) : new HSSFRichTextString(prompt));
cell.setCellComment(comment);

而如果不去手动设置则显示正常

clipboard.png

代码

final CreationHelper factory = this.workbook.getCreationHelper();
final ClientAnchor anchor = factory.createClientAnchor();
  anchor.setCol1(tempCol.get());
  anchor.setCol1(tempCol.get() + 3);
  anchor.setRow1(finalStartRow);
  anchor.setRow1(finalStartRow + 3);
final Comment comment = drawing.createCellComment(anchor);
comment.setString(this.excelType == ExcelType.XLSX ? new XSSFRichTextString(prompt) : new HSSFRichTextString(prompt));
cell.setCellComment(comment);

但这样在需要导出多个批注时仍然存在错误

java.lang.IllegalArgumentException: Multiple cell comments in one cell are not allowed, cell: A1

不清楚发生了什么,有人遇到过么?


官方示例

阅读 3.6k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题