preserve Excel charts

Topics: Developer Forum, User Forum
Nov 22, 2010 at 10:12 PM



Within a .xls (not xlsx), I have a default chart of Excel on a sheet.

Although I do not overwrite the visualized cells and rows, the chart seems to be removed after saving the file with phpexcel.

Is there a tutorial how to add charts into a .xls template which is not to be removed after processing?


Thanks for help

Nov 23, 2010 at 7:48 AM

At present this is not possible: not until chart capability has been built into PHPExcel. Initial chart reading/writing should be in the next release, but only for xlsx files.

Nov 23, 2010 at 7:52 AM

If I create a separate sheet with charts accessing data from other sheets in excel5, can i copy this sheet into the output excel file without touching the specific sheet's content?

Nov 23, 2010 at 8:10 AM

Unfortunately not.

The PHPExcel Readers load all the data that they can "understand" from a loaded workbook, ignoring anything that they cannot "understand". This means that the PHPExcel object has no "knowledge" that a chart even existed in the original workbook file. When the file is saved, the Writers can only create those elements that exist in the PHPExcel object, but no charts exist in the PHPExcel object, so no chart can be written. Until I've completed writing code for the PHPExcel object to hold chart information, and modified the Readers to load that information from a workbook into the PHPExcel object, and the Writers to save it, charts won't be supported.

Currently, I've built the code objects for storing chart information in the PHPExcel object, and updated the Excel2007 Reader to load that information, and am working on the Excel2007 Writer so that the chart information can be saved. This is intended for the next release. Updating the Excel5 Reader and Writer will follow in due course, but won't be available until next year.