PHP Excel无法保存在文件夹中

问题描述 投票:0回答:1

我想将我的excel文件保存到我的服务器。

文件夹位置是public_html / PHPExcel / Generated /

请参见下面的代码:

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


        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
        $objWriter->save(str_replace(__FILE__,'public_html/PHPExcel/generated/filename.xls',__FILE__));

谢谢

php phpexcel
1个回答
0
投票

希望对您有帮助。

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");;
header("Content-Disposition: attachment;filename=$filename");
header("Content-Transfer-Encoding: binary ");
$filename= 'xyz.xlsx';
$objWriter->save($filename);
© www.soinside.com 2019 - 2024. All rights reserved.