我有以下脚本
$this->load->library('excel');
$filename = FCPATH.'assets/template/monthly_report.xlsx';
$filetype = PHPExcel_IOFactory::identify($filename);
$objReader = PHPExcel_IOFactory::createReader($filetype);
$objReader->setIncludeCharts(TRUE);
$this->objExcel = $objReader->load($filename);
$this->objExcel->setActiveSheetIndex(0);
$sheet = $this->objExcel->getActiveSheet();
$sheet->setCellValue('A3', $process->process_name);
$last_num = 2; // row terakhir
$last_num_counter = 2; // row terakhir untuk counter
for($i = 4; $i <= $date_max + 3; $i++){
$cell = $this->translate_cell($i);
$sheet->setCellValue($cell.'2', date(($i - 3).'-M'));
}
foreach($schedules as $schedule){
}
$filename='Laporan Bulanan.xlsx';
header('Content-Type: application/vnd.ms-excel'); //mime type
header('Content-Disposition: attachment;filename="'.$filename.'"'); //tell browser what's the file name
header('Cache-Control: max-age=0'); //no cache
// PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);
$objWriter = PHPExcel_IOFactory::createWriter($this->objExcel, $filetype); //Excel2007
$objWriter->setIncludeCharts(TRUE);
$objWriter->save('php://output');
脚本正在加载xlsx文件作为模板,模板本身包含图形/图表。因此,我所要做的就是替换单元格中的数据,然后将其保存,不对图表内容进行任何触摸,然后保存。但是,它在生成的xlsx
文件的开头产生错误,它说
<p>Severity: Warning</p>
<p>Message: PHPExcel_Reader_Excel2007_Chart::getAttribute(): Node no longer exists</p>
<p>Filename: Excel2007/Chart.php</p>
<p>Line Number: 40</p>
我不知道这个错误,请有人救我的一天。