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.
使用npoi 导出可编辑的word饼图,仅限于office 2007
最新推荐文章于 2023-11-01 13:44:17 发布