简体   繁体   中英

How to get DataXML from Slide Diagram in Powerpoint using Apache POI

I have added one smart art shape in the Microsoft power point presentation slide. I want to get the data of that diagram in Java using apache POI.

How to retrieve the complete data.xml from first slide of presentation. I opened the presentation and following is the hierarchy of presentation.

在此处输入图片说明

I want to retrieve the data from first slide smart art diagram in XML ( complete data1.xml )

Following is the code for getting first slide i have developed so far.

public static void main(String[] args) {
    // TODO Auto-generated method stub
    final String filename = "resources/fptbenchmark/Powerpoint Import.pptx";

    try {
        XMLSlideShow ppt = new XMLSlideShow(new FileInputStream(filename));
        ppt.getSlides()[0]. //here first slide
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }


}

Assuming you know you'll always want /ppt/diagrams/data1.xml , then your code would want to continue with:

OPCPackage pkg = ppt.getPackage();
PackagePart data1 = pkg.getPart(
       PackagingURIHelper.createPartName("/ppt/diagrams/data1.xml"));
InputStream data1Inp = data1.getInputStream();

Then pass that InputStream to your XML parsing code to process

If you need to find the part dynamically based on the slide, you'll want to check the Relationships defined on your Slide part, and go from there

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM