import org.apache.poi.ss.usermodel.*;
private void setCommentsOfPoiCell(int row,int col, Cell poiCell,Row poiRow,String columnComment){
//增加批注
if(StringUtils.isNotBlank(columnComment) && !"null".equals(columnComment)){
ClientAnchor anchor = new XSSFClientAnchor();
//dx1、dy1、dx2、dy2 四个参数是坐标点
//dx1、dy1为起始单元格的x、y坐标,dx2、dy2为结束单元格的x、y坐标
anchor.setDx1(0);
anchor.setDx2(0);
anchor.setDy1(0);
anchor.setDy2(0);
//col1、row1、col2、row2 四个参数是编辑和显示批注时的大小
//col1、row1为单元格的起始列、行,col2、row2为单元格的终止列、行
anchor.setCol1(col);
anchor.setRow1(row);
anchor.setCol2(col+2);
anchor.setRow2(row+4);
Drawing draw = poiRow.getSheet().createDrawingPatriarch();
Comment commentOfCell = draw.createCellComment(anchor);
commentOfCell.setString(new XSSFRichTextString(columnComment));
poiCell.setCellComment(commentOfCell);
}
}