0
我使用php-script创建了一个使用PHPExcel库的简单.xlsx文件。但是,当我想在Win7上的MS Excel 2010中打开它时,出现文件格式错误或文件已损坏的错误消息。试图从互联网上的几种可能的解决方案,但没有为我工作。 ($ suffix){ $ this-> PHPExcel = new PHPExcel();}}在Excel中打开创建的文件时出现PHPExcel错误
$year = date('y');
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Cache-Control: max-age=0');
$this->objWriter = PHPExcel_IOFactory::createWriter($this->PHPExcel, 'excel5');
$this->objWriter->save('tmp/controlling_'.$year.'_'.$suffix.'.xlsx');
$_SESSION['counter'] = 0;
exit();
}
希望你能帮助我,会话的就是计数的东西
你实际上并没有发送任何数据到浏览器...... – Jon 2013-02-11 10:40:22
正如@Jon注意到的那样,您正在准备数据,但您从不“回声”出来。所以你的文件是空白的。 – Peon 2013-02-11 10:44:01
@Dainis - not echo,保存到php://输出 – 2013-02-11 10:48:52