Download Excel file with images using PHPExcel

I am currently working on a project that should display excel files (xls, xlsx, csv) in a browser. So far I have tried and used the PHPExcel library and was able to display the excel file (code below)

$opendoc     = $userDoc;
$objReader   = new PHPExcel_Reader_Excel2007();
$objPHPExcel = $objReader->load($opendoc);
$objWriter   = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
$objw        = $objWriter;
$objw->writeAllSheets(); 
$objw->save('php://output');

The problem I am facing is that this code does not support displaying images (charts, diagrams, etc.) inside an excel file. Any ideas? Thanks in advance!

+4
source share
1 answer

Errr ..... yes, yes. Have you read the documentation or looked at examples? Images are supported directly, and (unless you have indicated that PHPExcel only loads data) you should always download.

, PHPExcel, PHPExcel, . (Example)

$opendoc     = $userDoc;
$objReader   = new PHPExcel_Reader_Excel2007();

$objReader->setIncludeCharts(TRUE);

$objPHPExcel = $objReader->load($opendoc);
$objWriter   = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
$objw        = $objWriter;

$objw->setIncludeCharts(TRUE);

$objw->writeAllSheets(); 
$objw->save('php://output');
+1

All Articles