Kerwin | 1 Dec 05:50 2011
Picon

Updating Charts in a PPTX template

Hi All,

I have a PPTX template with multiple charts as placeholders that need to be
updated with data.
I could not find documentation on how to update a given chart in a PPTX
file directly. I have written some code below to be able to do this. Could
you please let me know if this is the best way to update multiple charts in
a PPTX file?.
I essentially read the chart.xml and then read the related embedded Excel
package. I am successful in reading the chart.xml but cannot read the
embedded excel XML accurately as I could not find methods to differentiate
the series and values using getsheetdata(). If I use XSSF I am able to
update the excel but when I click on the sheet and return to the chart the
additional series added is removed. Please suggest any better way to
update the chart.

Code:

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackagePartName;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.apache.poi.xssf.model.SharedStringsTable;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
(Continue reading)

Yegor Kozlov | 2 Dec 10:16 2011
Picon

Re: Updating Charts in a PPTX template

We don't have a usermodel API to work with charts in PPTX. You took
the right approach because direct manipulation with low-level xml
beans is the only way to do that.

On Thu, Dec 1, 2011 at 8:50 AM, Kerwin <kerwin747 <at> gmail.com> wrote:
> Hi All,
>
> I have a PPTX template with multiple charts as placeholders that need to be
> updated with data.
> I could not find documentation on how to update a given chart in a PPTX
> file directly. I have written some code below to be able to do this. Could
> you please let me know if this is the best way to update multiple charts in
> a PPTX file?.
> I essentially read the chart.xml and then read the related embedded Excel
> package. I am successful in reading the chart.xml but cannot read the
> embedded excel XML accurately as I could not find methods to differentiate
> the series and values using getsheetdata(). If I use XSSF I am able to
> update the excel but when I click on the sheet and return to the chart the
> additional series added is removed. Please suggest any better way to
> update the chart.
>

There can be many reasons why the added series is disappearing. Most
likely you don't update all the required xml bits.

Open the template with chart placeholders in PowerPoint and update the
data.  Then unzip the updated file  and compare it with the source
template and with a file updated by your code. This way you can figure
out what you missed .

(Continue reading)

Kerwin | 6 Dec 06:14 2011
Picon

Re: Updating Charts in a PPTX template

Hi Yegor,

Thankyou for your reply. We know now that we are on the right track!. Once
you get to know how to work with the XML it all falls into place.

--
View this message in context: http://apache-poi.1045710.n5.nabble.com/Updating-Charts-in-a-PPTX-template-tp5037605p5051033.html
Sent from the POI - User mailing list archive at Nabble.com.
Ankit Kapur | 5 Nov 17:16 2012
Picon

Re: Updating Charts in a PPTX template

Kerwin <kerwin747 <at> gmail.com> writes:

> 
> Hi Yegor,
> 
> Thankyou for your reply. We know now that we are on the right track!. Once
> you get to know how to work with the XML it all falls into place.
> 
> --
> View this message in context:
http://apache-poi.1045710.n5.nabble.com/Updating-Charts-in-a-PPTX-template-tp5037605p5051033.html
> Sent from the POI - User mailing list archive at Nabble.com.
> 

Hi Yegor/Kerwin,

I've been trying to edit chart data using the approach Kerwin mentioned, but I'm
not getting results. Please drop me a few hints if you've made any progress, or
found an alternative to edit charts.

- Ankit
Yegor Kozlov | 7 Nov 09:36 2012
Picon

Re: Updating Charts in a PPTX template

I committed an example that shows how to create a Pie Chart from a template:

https://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java

Follow the pattern for other types of charts.

Yegor

On Mon, Nov 5, 2012 at 5:16 PM, Ankit Kapur <ankit.kapur <at> jpmchase.com> wrote:
> Kerwin <kerwin747 <at> gmail.com> writes:
>
>>
>> Hi Yegor,
>>
>> Thankyou for your reply. We know now that we are on the right track!. Once
>> you get to know how to work with the XML it all falls into place.
>>
>> --
>> View this message in context:
> http://apache-poi.1045710.n5.nabble.com/Updating-Charts-in-a-PPTX-template-tp5037605p5051033.html
>> Sent from the POI - User mailing list archive at Nabble.com.
>>
>
>
> Hi Yegor/Kerwin,
>
> I've been trying to edit chart data using the approach Kerwin mentioned, but I'm
> not getting results. Please drop me a few hints if you've made any progress, or
> found an alternative to edit charts.
>
(Continue reading)


Gmane