资源简介
poi 版本 3.17 文件中包含 模板 测试main 数据类 需要调整下 路径
/**
* @Description:
* @Author: xsr
* @date : 2018/7/22 9:41
*/
public static void makePiePpt(List dataList) throws Exception {
//打开模板ppt
String mtemplateName = "E:/PIE/mtemplate/PIE" + dataList.size() + ".pptx";
String path ="E:/PIE/NewPPT/NewPIE" + dataList.size() + ".pptx";
XMLSlideShow pptx = new XMLSlideShow(new FileInputStream(mtemplateName));
pptx.setPageSize(new Dimension(960, 580));
for (int i = 0; i < dataList.size(); i++) {
makePiePpt(pptx, i, dataList);
}
//保存文件
OutputStream out = new FileOutputStream(path);
pptx.write(out);
out.close();
System.out.println("导出成功");
}
/**
* @Description:
* @Author: xsr
* @date : 2018/7/27 5:41
*/
public static void makePiePpt(XMLSlideShow pptx, Integer pieNum, List dataList) throws Exception {
//获取第一个ppt页面
XSLFSlide slide = pptx.getSlides().get(0);
//遍历第一页元素找到图表
XSLFChart chart;
List poixmlDocumentParts = new ArrayList();
for (POIXMLDocumentPart part : slide.getRelations()) {
if (part instanceof XSLFChart) {
chart = (XSLFChart) part;
poixmlDocumentParts.add(chart);
}
}
chart = (XSLFChart) poixmlDocumentParts.get(pieNum);
POIXMLDocumentPart xlsPart = chart.getRelations().get(0);
//把图表绑定到Excel workbook中
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet();
CTChart ctChart = chart.getCTChart();
CTPlotArea plotArea = ctChart.getPlotArea();
CTPieChart pieChart = plotArea.getPieChartArray(0);
// 获取图表的系列
CTPieSer ser = pieChart.getSerArray(0);
XSSFRow row0 = sheet.createRow(0);
// Series Text
CTSerTx tx = ser.getTx();
tx.getStrRef().
代码片段和文件信息
package com.adc.da.export.util;
import com.adc.da.reve.vo.PieData;
import org.apache.poi.POIxmlDocumentPart;
import org.apache.poi.hssf.util.CellReference;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xslf.usermodel.xmlSlideShow;
import org.apache.poi.xslf.usermodel.XSLFChart;
import org.apache.poi.xslf.usermodel.XSLFSlide;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openxmlformats.schemas.drawingml.x2006.chart.*;
import java.awt.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class pie {
public static void main(String[] args) throws Exception {
List dataList = new ArrayList<>();
PieData pieData = new PieData();
pieData.settitleName(“车型类别(一)“);
pieData.setLegengName(Arrays.asList(“敞篷跑车“ “双门轿跑车“ “超级跑车“ “2+2 跑车“));
pieData.setLegengValue(Arrays.asList(“15“ “25“ “35“ “45“));
dataList.add(pieData);
pieData = new PieData();
pieData.settitleName(“车型类别(二)“);
pieData.setLegengName(Arrays.asList(“敞篷跑车1“ “双门轿跑车1“ “超级跑车1“ “2+2 跑车1“));
pieData.setLegengValue(Arrays.asList(“90“ “60“ “30“ “10“));
dataList.add(pieData);
pieData = new PieData();
pieData.settitleName(“车型类别(三)“);
pieData.setLegengName(Arrays.asList(“敞篷跑车2“ “双门轿跑车2“ “超级跑车2“ “2+2 跑车2“));
pieData.setLegengValue(Arrays.asList(“60“ “15“ “20“ “10“));
dataList.add(pieData);
// pieData = new PieData();
// pieData.settitleName(“车型类别(四)“);
// pieData.setLegengName(Arrays.asList(“敞篷跑车3“ “双门轿跑车3“ “超级跑车3“ “2+2 跑车3“));
// pieData.setLegengValue(Arrays.asList(“10“ “80“ “20“ “10“));
// dataList.add(pieData);
makePiePpt(dataList);
}
/**
* @Description:反向查询导出(**)
* @Author: xieshengrui
* @date : 2018/7/22 9:41
*/
public static void makePiePpt(List dataList) throws Exception {
//打开模板ppt
String mtemplateName = “E:/PIE/mtemplate/PIE“ + dataList.size() + “.pptx“;
String path =“E:/PIE/NewPPT/NewPIE“ + dataList.size() + “.pptx“;
xmlSlideShow pptx = new xmlSlideShow(new FileInputStream(mtemplateName));
pptx.setPageSize(new Dimension(960 580));
for (int i = 0; i < dataList.size(); i++) {
makePiePpt(pptx i dataList);
}
//保存文件
OutputStream out = new FileOutputStream(path);
pptx.write(out);
out.close();
System.out.println(“导出成功“);
}
/**
* @Description:反向查询导出(***)
* @Author: xieshengrui
* @date : 2018/7/27 5:41
*/
public static void makePiePpt(xmlSlideShow pptx Integer
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 54765 2018-09-03 15:36 multi-pie\PIE\mtemplate\PIE1.pptx
文件 72546 2018-09-03 15:37 multi-pie\PIE\mtemplate\PIE2.pptx
文件 92039 2018-09-03 15:38 multi-pie\PIE\mtemplate\PIE3.pptx
文件 102392 2018-09-03 15:39 multi-pie\PIE\mtemplate\PIE4.pptx
文件 76842 2018-09-03 15:40 multi-pie\PIE\NewPPT\NewPIE3.pptx
..A..H. 165 2018-09-03 15:40 multi-pie\PIE\NewPPT\~$NewPIE3.pptx
文件 6390 2018-09-03 15:25 multi-pie\pie.java
文件 1158 2018-08-30 11:50 multi-pie\PieData.java
目录 0 2018-09-03 15:43 multi-pie\PIE\mtemplate
目录 0 2018-09-03 15:41 multi-pie\PIE\NewPPT
目录 0 2018-09-03 15:41 multi-pie\PIE
目录 0 2018-09-03 15:44 multi-pie
----------- --------- ---------- ----- ----
406297 12
相关资源
- springmvc+poi 导入导出文件controller以及
- NPOI开源的.NET读写Excel、WORD等文档的类
- POI和JFreeChart框架实现生成Excel文件生
- SharePoint Server 2016 Enterprise Key
- Team Foundation Server 2017 & SharePoint Serve
- XianCh_point.shp
- 百度poi爬取插件
- NPOI2.0.1dll文件
- NPOI动态库dll打包,已验证
- 二维双极Euler-Poisson方程的稳定解的存
- Blow up for the solutions of the Euler-Poisson
- poi excel 模板读取并导出带公式的exc
- Synergistic effect of surfactants on the stabi
- IEEE Standard for Floating-Point Arithmetic
- npoi.dll EXCEL导出DLL
- 哈利波特的魔法书PowerPoint模板.rar
- E-Pointer红烛电子教鞭v2.5注册版.rar
- poi-3.9.zip
- 原创-NPOI操作Word文档中的Bookmark标签以
- 使用poi方式导出excel(分多个sheet导出
- NPOI for .net 4.0 .net 4.5.1
- NPOI 2.2.1 dll包
- NPOI2.3最新版本
- NPOI 2.1
- Apache POI 3.9 API
- NPOI.dll各种DLL文件集合
- NPOI 2.3.0 最新版
- NPOI官方最新原版2.4.0
- NPOI最新dll 2.4.1
- IEEE 754 Floating point Arithmetic
评论
共有 条评论