Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chart Not Loaded in PHPExcel

Tags:

php

phpexcel

Hi I have just loaded a xlsx file with graph,but the graph is not displayed in output.

This is my code :

 $objPHPExcel=$objPHPExcel_new = new PHPExcel();
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objReader->load("../Graph_sample.xlsx");



$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('result.xlsx'); 
like image 916
Sundar Avatar asked Mar 22 '23 07:03

Sundar


1 Answers

Because most users don't want to load charts by default (loading/saving charts is a speed and memory overhead), you have to explicitly tell PHPExcel that you want to load them using setIncludeCharts():

$objPHPExcel=$objPHPExcel_new = new PHPExcel();
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setIncludeCharts(TRUE);
$objPHPExcel = $objReader->load("../Graph_sample.xlsx");

and when writing

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->setIncludeCharts(TRUE);
$objWriter->save('result.xlsx'); 
like image 123
Mark Baker Avatar answered Mar 31 '23 18:03

Mark Baker