我的docx文件中有一个3D饼图。我想更改使用POI的饼图数据,以下是我的代码。我可以获取图表xml数据,但是如何将其保存到docx?
OPCPackage docx = XWPFDocument.openPackage("test2.docx");
XWPFDocument document = new XWPFDocument(docx);
List<POIXMLDocumentPart> parts = document.getRelations();
for (POIXMLDocumentPart part : parts){
if("application/vnd.openxmlformats-officedocument.drawingml.chart+xml".equalsIgnoreCase(part.getPackagePart().getContentType())){
PackagePart pkg = part.getPackagePart();
ChartSpaceDocument cht = ChartSpaceDocument.Factory.parse(pkg.getInputStream());
CTChartSpace chtSpc = cht.getChartSpace();
CTPieChart pieChart = chtSpc.getChart().getPlotArea().getPieChartArray(0);
}
}