嗨,我刚刚加载了一个带有图形的 xlsx 文件,但该图形未显示在输出中。

这是我的 代码:

 $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');

最佳答案

因为大多数用户不希望默认加载图表(加载/保存图表是一种速度和内存开销),您必须使用 setIncludeCharts() 明确告诉 PHPExcel 您要加载它们:

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

并且在写作时
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->setIncludeCharts(TRUE);
$objWriter->save('result.xlsx');

关于php - PHPExcel中未加载图表,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20562810/

10-09 00:42