Page 1 of 1

read all charts from docx file

PostPosted: Thu Jan 12, 2023 1:19 am
by ajayjha
How can i extract all charts from docx file and save it into localstore as images.
Is this possible using docx4j api (java)?
can anybody provide me code for this.

Re: read all charts from docx file

PostPosted: Sat Jan 14, 2023 12:17 pm
by jason
Sorry, docx4j can't do this, and nor afaik can Apache POI.

The chart data is present in the package of course, but no corresponding image, so you have to generate that yourself.

Some options to explore:

1. documents4j (integrated with docx4j), but it seems some work may be required to get Excel to handle charts: https://stackoverflow.com/questions/343 ... ocuments4j and https://github.com/documents4j/documents4j/issues/98

2. automate excel some other way

3. Microsoft Graph? https://www.docx4java.org/blog/2020/09/ ... x4j-8-2-3/

4. LibreOffice/OpenOffice?

5. Use JFreeChart to make your own chart from the data in the package (how much work this would be depends on how many of Excel's chart types you need to support, and how closely your chart needs to match the appearance produced by Office

6. Aspose? (commercial)