How can I copy a Graph object?

Topics: Developer Forum
Nov 5, 2009 at 2:49 AM

Hi,

I'm having a problem with copying a graph object from template Excel5 file to new Excel5 file.

I'm using CakePHP1.2 and PHPExcel 1.7.1. The code is below.

         // read template xls file  
            $reader = PHPExcel_IOFactory::createReader('Excel5');
            $excel = $reader->load(EXCEL_FILE_PATH."template.xls");
            // set active sheet
            $excel->setActiveSheetIndex(0);
            $sheet = $excel->getActiveSheet();
            // output excel file
            $writer = PHPExcel_IOFactory::createWriter($excel, 'Excel5');
            $writer->save(EXCEL_FILE_PATH."output.xls");

And there are a graph object in the template excel. This template excel has two sheets and one is main and another is the base data for the graph in the main sheet.

I expected that a copied file of template.xls which the name is output.xls would be created. It's actually created, however only a graph object wasn't copied. Other than that, everything has been copied such as Font, Letter, Color, Border and even image.

All I want to do is copy a template file to output file and change some letters and base data for the graph in the output file.

Did I miss something? Any advice would be appreciated.

 

 

Coordinator
Nov 5, 2009 at 7:46 AM

Chart objects are not currently supported in PHPExcel, and so cannot be read from a template nor written to a new workbook. This is currently a work in progress, but as charting is a very complex piece of functionality, it is unlikely to be available for some time.

Nov 25, 2009 at 6:03 PM

Is there a best practice for inserting graphs into reports that use PHPExcel?  Perhaps rendering with pChart and then inserting as an image?

Coordinator
Nov 25, 2009 at 7:56 PM
MitchMcBride wrote:

Is there a best practice for inserting graphs into reports that use PHPExcel?  Perhaps rendering with pChart and then inserting as an image?

 Currently, that would be your best/only option.

I've been mapping out the classes/methods for handling charts within PHPExcel, but it's still a long way off before I have anything to show for my efforts.