“Excel found unreadable content” warning when opening Excel files made with PHPExcel

前端 未结 6 628
情深已故
情深已故 2020-12-31 02:44

I\'m trying to download Excel files (xlsx) using PHPExcel as follows.

require_once(\"../../phpExcel/Classes/PHPExcel.php\");
require_once(\"../../phpExcel/Cl         


        
6条回答
  •  误落风尘
    2020-12-31 03:06

    I Put just exit; After

    PHPExcel_IOFactory::createWriter($phpExcelObject, 'Excel2007')->save("php://output");

    and it work's for me :)

       $file_name .= "_".\Carbon\Carbon::now()->format('d_m_Y_H_i').'.xlsx';
    
        // Prepare To Download
        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
        header('Content-Disposition: attachment;filename='.$file_name);
        header('Cache-Control: max-age=0');
        header('Pragma: public');
        PHPExcel_IOFactory::createWriter($phpExcelObject, 'Excel2007')->save("php://output");
        exit;
    

提交回复
热议问题