在 Excel 中设置评论(使用 apache poi)
Setting Comments in Excel (with apache poi)
我正在尝试将单元格评论设置为一组单元格,对于页面右侧的单元格,评论具有适当的大小,但对于前一列的其他单元格页面,它们的大小开始减小,没有明显的解释(对我来说)。
情况截图:
用正确的尺码评论
http://prntscr.com/7ez65x
对于之前专栏中的那些,评论根本没有宽度...就像它们自己折叠起来一样。
我用来生成评论的代码是:
protected void setCellComment(Cell cell, String message)
{
Drawing drawing = cell.getSheet().createDrawingPatriarch();
CreationHelper factory = cell.getSheet().getWorkbook().getCreationHelper();
ClientAnchor anchor = factory.createClientAnchor();
int width = 3;
int height = 2;
anchor.setCol1(cell.getColumnIndex());
anchor.setCol2(cell.getColumnIndex() + width);
anchor.setRow1(cell.getRowIndex());
anchor.setRow2(cell.getRowIndex() + height);
anchor.setDx1(100);
anchor.setDx2(100);
anchor.setDy1(100);
anchor.setDy2(100);
Comment comment = drawing.createCellComment(anchor);
RichTextString str = factory.createRichTextString(message);
comment.setString(str);
cell.setCellComment(comment);
}
请帮忙!
非常感谢
我解决了删除 sheet 的冻结窗格的问题。冻结窗格和评论之间的组合可能存在错误。
我正在尝试将单元格评论设置为一组单元格,对于页面右侧的单元格,评论具有适当的大小,但对于前一列的其他单元格页面,它们的大小开始减小,没有明显的解释(对我来说)。
情况截图:
用正确的尺码评论 http://prntscr.com/7ez65x
对于之前专栏中的那些,评论根本没有宽度...就像它们自己折叠起来一样。
我用来生成评论的代码是:
protected void setCellComment(Cell cell, String message)
{
Drawing drawing = cell.getSheet().createDrawingPatriarch();
CreationHelper factory = cell.getSheet().getWorkbook().getCreationHelper();
ClientAnchor anchor = factory.createClientAnchor();
int width = 3;
int height = 2;
anchor.setCol1(cell.getColumnIndex());
anchor.setCol2(cell.getColumnIndex() + width);
anchor.setRow1(cell.getRowIndex());
anchor.setRow2(cell.getRowIndex() + height);
anchor.setDx1(100);
anchor.setDx2(100);
anchor.setDy1(100);
anchor.setDy2(100);
Comment comment = drawing.createCellComment(anchor);
RichTextString str = factory.createRichTextString(message);
comment.setString(str);
cell.setCellComment(comment);
}
请帮忙!
非常感谢
我解决了删除 sheet 的冻结窗格的问题。冻结窗格和评论之间的组合可能存在错误。