Using phpExcel to download xlsx file using Google

2019-07-29 04:46发布

I'm writing a php web app to create and download an xlsx file, using Google App Engine:

$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheet(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 4);

header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="01simple.xls"');
header('Cache-Control: max-age=0');

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;

When I run this app locally, it creates and downloads a new xlsx file correctly, but it fails when deployed since Google App Engine currently does not support 'php://output' (feature request here)

'php://temp' and 'php://memory' are supported, but I'm not finding much documentation on how/if I can write and download a file using those options. Does anyone have a good solution to this problem?

0条回答
登录 后发表回答