singerla / pptx-automizer

A template based pptx generator for Node.js
MIT License
68 stars 12 forks source link

question: reading/writting ppt with charts #110

Closed llermaly closed 3 months ago

llermaly commented 4 months ago

Hello!, congrats for this awesome library and so well maintained!.

I'm testing the library and could not get to a clear answer about if this library can be used for what I need.

I want to read a powerpoint with charts/tables, then programmatically replace the values of the chart/pages and save back I don't need to change any of the slides structure, just replace chart and table values. I was able to write values on an existing ppt, but not to read the current labels/values of the chart. I wonder if there is a way to read the powerpoint charts in the same format you use to modify them.

Thank you

singerla commented 4 months ago

Hi! Thank you so much, and I'm happy about anybody who can use this library :)

There are only a few "readers" implemented, but please take a look at https://github.com/singerla/pptx-automizer/issues/102 , there is an example about reading data from a chart.

Each modifier to set xml data can also be a reader.

I'll come back to this next week!

singerla commented 4 months ago

You can also take a look at https://github.com/singerla/pptx-automizer#create-a-new-modifier

It is much simpler to edit a table on a slide compared to a chart; building a table data reader should be easier.

llermaly commented 4 months ago

Thank you @singerla ! this is a whole new world for me. I will take a look at the issues and share with you any findings.

singerla commented 4 months ago

This is for reading chart data: read-chart-data.test.ts and this demonstrates on how to read table data: read-table-data.test.ts

llermaly commented 3 months ago

Thanks again @singerla , You can go ahead and close this one after reading. I found some things I think its a better idea to create independent issues.

In conclusion:

  1. There is no way to read a chart/table in the same format you use to write it. You read it as an array of arrays, you write it as an array of objects. I'm not sure if this is something that can be created as a generic parser (specially when dealing with combo charts). I really hope I'm wrong with this one :(
  2. There is a implementation to read chart data which reads the XML, #102 will read from the underlying xls which is interesting because I found additional data like calculations in the xls which is useful for context in my use case.
singerla commented 3 months ago

Hi @llermaly,

regarding 1.: I'm sorry, but there is currently no function to read/write in one go. In my use cases, there is alway dummy-data in all templates. You could take a look at automizer-data, which I am using to prepare data objects for pptx-automizer. We could create a Modelizer with DataPoints from a data reader, transform and convert it.

regarding 2.: I used to remove all kinds of excel calculations from underlying xls, because you might need to manipulate a calculation chain, which is out of scope.