Why cannot I create xlsx files in phpexcel?
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');header('Content-Disposition: attachment;filename="fee_detail.xlsx"');header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');$objWriter->save( 'php://output');
Why cannot I create an xlsx file.
header('Content-Type: application/vnd.ms-excel');header('Content-Disposition: attachment;filename="fee_detail.xls"');header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');$objWriter->save('php://output');
You can create xls files.
Reply to discussion (solution)
Can't you do that?
The file cannot be downloaded, or cannot be opened after the download?
Under normal circumstances, the system will prompt you to save or open the file, but when you create xlsx, the system will directly prompt "loading the page for a business trip, no file found"
Can't you do that?
The file cannot be downloaded, or cannot be opened after the download?
The file cannot be downloaded.
If there is a mistake, the original error message will be posted.
If there is a mistake, the original error message will be posted.
There is no error message. I added the following code in the file header to generate an xlsx file.
ini_set('display_errors', TRUE);ini_set('display_startup_errors', TRUE);
However, if you encounter a problem and cannot open the file, the system prompts "the file format or file extension is invalid. Make sure that the file is not damaged.
I think the code should be fine. this code can generate an xls file and open the xls file.
The error message is put in the file, so the file cannot be opened normally.
You can use a text editor to open the file, and you will be able to see the error message in "garbled ".
The error message is put in the file, so the file cannot be opened normally.
You can use a text editor to open the file, and you will be able to see the error message in "garbled ".
The error message is put in the file, so the file cannot be opened normally.
You can use a text editor to open the file, and you will be able to see the error message in "garbled ".
Thank you, prawns. The cause is found. ZipArchive not found
After configuring the php. ini file, the problem is solved.
Your php version is relatively low.