Java为Excel导出增加批注(POI)

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);
        }
    }

 

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值