我已设法创建并保存excel文件:
// Rename the file
$fileName = URL . "MODEL/case" . $caseNO . ".xlsx";
// Write the file
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $fileType);
$objWriter->save($fileName);
我想现在PHPExcel自动运行Excel,打开创建的文件并最大化它.
可能吗?即使Excel已经运行,这还能工作吗?
谢谢您的帮助,
多纳托
解决方法:
根据我的上述评论,您只能强制下载选项.为此,您可以这种方式设置标题 –
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
header("Content-Disposition: attachment;filename=\"filename.xlsx\"");
header("Cache-Control: max-age=0");
参考 – PHP Excel Reader
如需更多选项,您还可以查看备忘单 – Cheat Sheet
虽然最好的方式在这里阅读 – Codeplex
编辑
做这样的事情 –
$excel = new PHPExcel();
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="your_name.xls"');
header('Cache-Control: max-age=0');
// Do your stuff here
$writer = PHPExcel_IOFactory::createWriter($excel, 'Excel5');
// This line will force the file to download
$writer->save('php://output');