2012-07-10 35 views

回答

1

是PHP-ExcelReader支持Excel圖表由PHP讀取/寫入和顯示,您可以使用下面的代碼來做到這一點: -

error_reporting(E_ALL); 
date_default_timezone_set('Europe/London'); 
require_once '../Classes/PHPExcel/IOFactory.php'; 
require_once '../Classes/PHPExcel.php'; 
$excel2 = PHPExcel_IOFactory::createReader('Excel2007'); 

/*Enable chart read on excel*/ 
$excel2->setIncludeCharts(TRUE); 
/*Enable chart read on excel*/ 

$excel2 = $excel2->load('excelname.xlsx'); // Empty Sheet 

/*update cell data if you required */ 
$excel2->getActiveSheet()->setCellValue('B6', '2'); 
$excel2->getActiveSheet()->setCellValue('B7', '1'); 
$excel2->getActiveSheet()->setCellValue('B8', '3'); 
/*-----------------------------*/ 

$objWriter = PHPExcel_IOFactory::createWriter($excel2, 'Excel2007'); 
/*Enable chart write on excel*/ 
$objWriter->setIncludeCharts(TRUE); 
/*Enable chart write on excel*/ 
$objWriter->save('excelout.xlsx');