How to export in phpexcel click Export to open the save dialog box and select save path to save

Source: Internet
Author: User
How to export in phpexcel click Export to open the save dialog box and select the save path to save PhpExcel export php

When you export data using phpexcel, you can directly generate an excel file and cannot save it locally. how can you click Export to bring up the save dialog box and select the save path to save it, practical examples or ideas!


Reply to discussion (solution)

The file is generated on the server. If JavaScript points to the generated excel file that cannot be opened by the browser, will the file be downloaded?

I have never tried it.

Save ()

Changed:
Header ("Content-Type: application/force-download ");
Header ("Content-Type: application/octet-stream ");
Header ("Content-Type: application/download ");
Header ('content-Disposition: inline; filename = "'. $ FileName .'"');
Header ("Content-Transfer-Encoding: binary ");
Header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT ");
Header ("Last-Modified:". gmdate ("D, d m y h: I: s"). "GMT ");
Header ("Cache-Control: must-revalidate, post-check = 0, pre-check = 0 ");
Header ("Pragma: no-cache ");
$ ObjWriter-> save ('php: // output ');

// Sheet name
$ ObjPHPExcel-> getActiveSheet ()-> setTitle ('performance appraisal Statistics ');
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$ ObjPHPExcel-> setActiveSheetIndex (0 );
// Redirect output to a clients web browser (Excel5) notification download
$ Fn = "gxtj-policyear-policjd.xls ";
Header ('content-Type: application/vnd. ms-excel; charset = utf-8 ');
Header ("Content-Disposition: attachment; filename = $ fn ");
Header ('cache-Control: max-age = 0 ');
$ ObjWriter = PHPExcel_IOFactory: createWriter ($ objPHPExcel, 'excel5 ');
$ ObjWriter-> save ('php: // output ');
Exit;

Statement: This article is Liu Xing (http://deepfuture.iteye.com/) original, if reprint please indicate the source

Can this problem be solved?

Save ()

Changed:
Header ("Content-Type: application/force-download ");
Header ("Content-Type: application/octet-stream ");
Header ("Content-Type: application/download ");
Header ('content-Disposition: inline; filename = "'. $ FileName .'"');
Header ("Content-Transfer-Encoding: binary ");
Header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT ");
Header ("Last-Modified:". gmdate ("D, d m y h: I: s"). "GMT ");
Header ("Cache-Control: must-revalidate, post-check = 0, pre-check = 0 ");
Header ("Pragma: no-cache ");
$ ObjWriter-> save ('php: // output ');
Can you tell me the specifics? I used zendframework to pull data from the database in the background Action and put it in the excl document. the code was put without any response.


Save ()

Changed:
Header ("Content-Type: application/force-download ");
Header ("Content-Type: application/octet-stream ");
Header ("Content-Type: application/download ");
Header ('content-Disposition: inline; filename = "'. $ FileName .'"');
Header ("Content-Transfer-Encoding: binary ");
Header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT ");
Header ("Last-Modified:". gmdate ("D, d m y h: I: s"). "GMT ");
Header ("Cache-Control: must-revalidate, post-check = 0, pre-check = 0 ");
Header ("Pragma: no-cache ");
$ ObjWriter-> save ('php: // output ');
Can you tell me the specifics? I used zendframework to pull data from the database in the background Action and put it in the excl document. the code was put without any response.

Not put it on .. Do you not need to change the variable name? Is your PHPEXCEL class $ objWriter instantiated? Change to your own.
Ps: Open the error prompt and check what the error is. if there is no response, it may be wrong.

Http://www.cnblogs.com/dahuzizyd/archive/2012/07/06/2579738.html

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.