如果插入多个批注,只会显示一个
其问题是每个批注对象只能插入一次。。。在其他单元格再次插入就会重新定位之类的。。。类似于重新赋值
解决办法就是新建多几个批注对象
/**
* 创建一列应用列头
*
* @param userinfosheet1
* @param userName
* @param list
* String数组的形式存放数据
*/
public void creatAppRowHead(HSSFSheet userinfosheet1, int naturalRowIndex,String[] list) {
HSSFRow row = userinfosheet1.createRow(naturalRowIndex - 1);
//创建绘图对象
HSSFPatriarch p=userinfosheet1.createDrawingPatriarch();
//获取批注对象
//(int dx1, int dy1, int dx2, int dy2, short col1, int row1, short col2, int row2)
//前四个参数是坐标点,后四个参数是编辑和显示批注时的大小.
HSSFComment comment=p.createComment(new HSSFClientAnchor(0,0,0,0,(short)3,3,(short)5,6));
HSSFComment comment1=p.createComment(new HSSFClientAnchor(0,0,0,0,(short)3,3,(short)5,6));
HSSFComment comment2=p.createComment(new HSSFClientAnchor(0,0,0,0,(short)3,3,(short)5,6));
//输入批注信息
HSSFRichTextString text = new HSSFRichTextString("输入格式:2017-06-01");
comment.setString(text);
comment1.setString(text);
comment2.setString(text);
for (int i = 0; i < list.length; i++) {
HSSFCell Cell = row.createCell(i);
Cell.setCellValue(list[i]);
Cell.setCellStyle(titleStyle);
}
row.getCell(1).setCellComment(comment);
row.getCell(22).setCellComment(comment1);
row.getCell(23).setCellComment(comment2);
}