Why cannot I create xlsx files in phpexcel?

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.