使用npoi 导出可编辑的word饼图,仅限于office 2007

这篇博客详细介绍了如何使用npoi库在Word文档中创建一个可编辑的饼图,适用于Office 2007。内容包括设置图表标题、图例位置、数据源等,以及饼图的样式和显示选项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 public static XWPFDocument CreatePie(int numbers,String countent, IList<Double> datas, IList<String> legend, XWPFDocument doc, ST_LegendPos legendLocal, int x1 = 200000,  int y1 = 0,int x2 = 6274310,  int y2 = 3116575,  String title = "销售额")
        {

            //数据接收
          //左上坐标 x1, y1, 右上 x2,y2
          //写入路径
            //title
            

            //图例


            //图例位置
           

            //内容文字

          


            //anchor
            XWPFDocument m_Docx = doc;
            //页面设置
            //A4:W=11906,h=16838
            //CT_SectPr m_SectPr = m_Docx.Document.body.AddNewSectPr();
            m_Docx.Document.body.sectPr = new CT_SectPr();
            CT_SectPr m_SectPr = m_Docx.Document.body.sectPr;
            //页面设置A4横向
            m_SectPr.pgSz.w = (ulong)16838;
            m_SectPr.pgSz.h = (ulong)11906;

            //插入饼图图表
            //插入xlsx
            //创建xlsx
            XSSFWorkbook workbook = new XSSFWorkbook();
            //创建表单1(饼图)
            ISheet sheet = workbook.CreateSheet("Sheet1");
            //表单1饼图数据
            //         销售额
            //第一季度 8.2
            //第二季度 3.2
            //第三季度 1.4
            //第四季度 1.2


           


            //设置title
            IRow row = sheet.CreateRow(0);
            ICell cell = row.CreateCell(0);
            cell = row.CreateCell(0);
            cell = row.CreateCell(1);
            cell.SetCellValue(title);

            //饼图图例加数值
            //判断 图例和数据是否一一对应

            if(datas.Count != legend.Count){

                throw new Exception("图例和数据数量不一样");

            }

            for (int i = 0; i < datas.Count; i++)
            {

                row = sheet.
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值