You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by "huyang19881115@163.com" <hu...@163.com> on 2021/12/17 10:05:58 UTC
how to create PPTX chart
find a example \poi-src-5.1.0\poi-examples\src\main\java\org\apache\poi\examples\xslf
something style i will try to use it create line , bar, pie, radar and so no......
ChartFromScratch.java
huyang19881115@163.com
发件人: huyang19881115@163.com
发送时间: 2021-12-17 17:13
收件人: dev
主题: how to create PPTX chart
我想 在 一个空白的 slide ppt 页面创建 饼图 柱状图 ,折线图 ,怎么去实现呢?
XSLFSlide slide = ppt.createSlide();
XSLFChart chart = ppt.createChart();
slide.addChart(chart,new Rectangle(50,50,150,200) );
XSSFWorkbook workbook = chart.getWorkbook();
XSSFSheet sheet = workbook.getSheetAt(0);
//标题列,文本列 .....
String[] categories = {"广告","游戏","文学"};
// 具体的数值
Double[] values = {100d,150d,200d};
sheet.createRow(0).createCell(0).setCellValue("标题设定.....");
for (int i = 1; i <= categories.length; i++) {
sheet.createRow(i).createCell(0).setCellValue(categories[i-1]);
sheet.createRow(i).createCell(1).setCellValue(values[i-1]);
}
//写入数据到 excel表中
workbook.write(chart.getPackagePart().getOutputStream());
不知道该怎么处理了?
huyang19881115@163.com