Phpexcel Why cannot generate xlsx file

Source: Internet
Author: User
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 the xlsx file could not be generated.

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 generate an XLS file.


Reply to discussion (solution)

Cannot generate XLSX, do you have an error message? or other informational messages

Tested to generate. xlsx, you $objwriter->save (' Php://output '), followed by exit (); try it.

Cannot generate XLSX, do you have an error message? or other informational messages


There is no error message, I added the following code in the header of the file, you can generate the xlsx file
Ini_set (' display_errors ', true); Ini_set (' display_startup_errors ', true);

However, a problem has been encountered that does not open the file, prompting "the file format or file name extension is invalid." Please make sure the file does not harm ... "information.

I think the code should be fine, this set of code can generate the XLS file, and can open the XLS file.

Tested to generate. xlsx, you $objwriter->save (' Php://output '), followed by exit (); try it.



Exit (); It's always been.
I added the following code to the file header to generate the xlsx file
Ini_set (' display_errors ', true); Ini_set (' display_startup_errors ', true);

However, a problem has been encountered that does not open the file, prompting "the file format or file name extension is invalid." Please make sure the file does not harm ... "information.
I think the code should be fine, this set of code can generate the XLS file, and can open the XLS file.

The reason was found, ziparchive not found
Configuration of the php.ini file, the problem solved.

  • 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.