Phpexcel Export How to implement click Export after popup Open Save dialog Select Save Path Save

Source: Internet
Author: User
Phpexcel Export How to implement click Export after pop-up open Save Dialog Select Save Path Save
When using Phpexcel export to find a call directly generated an Excel file, can not be saved to the local, how to implement click Export, Pop-up Save dialog box and choose Save Path to save it, find an example or ideas! Phpexcel Export PHP

Share to:


------Solution--------------------
The build is generated on the server bar with JS pointing to the generated Excel file browser cannot open it will prompt to download it?

Pure speculation has not been tried.
------Solution--------------------
Last save phase of the->save ()

Switch
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, 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 ');
------Solution--------------------
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-$year-$jd. 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

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

Can you solve it?
------Solution--------------------
  • 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.