栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

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

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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

 

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/921703.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号