How to select a path when Phpexcel is saved

Source: Internet
Author: User
How do I select a path when Phpexcel is saved?
How can I use Phpexcel to export Excel to choose Save path??
PHP Code
  Set_include_path (Get_include_path (). Path_separator. Lib_dir. Directory_separator. " Phpexcel ". Directory_separator. " Classes "); include ' phpexcel.php '; include ' phpexcel/iofactory.php '; $objPHPExcel = new Phpexcel (); $objPHPExcel GetProperties ()->setcreator ("Maarten Balliauw"), $objPHPExcel->getproperties ()->setlastmodifiedby (" Maarten Balliauw "), $objPHPExcel->getproperties ()->settitle (" Office "XLSX Test Document"), $objPHPExcel- >getproperties ()->setsubject ("Office" XLSX Test Document "), $objPHPExcel->getproperties () SetDescription ("Test document for Office" XLSX, generated using PHP classes. "); $objPHPExcel->getproperties ()->setkeywords ("Office openxml PHP"), $objPHPExcel->getproperties () Setcategory ("Test result file"), $objPHPExcel->setactivesheetindex (0); $objPHPExcel->getactivesheet () Setcellvalue (' A1 ', ' Hello '), $objPHPExcel->getactivesheet ()->setcellvalue (' B2 ', ' world! '); $objPHPExcel->getactivesheet ()->setcellvAlue (' C1 ', ' Hello '), $objPHPExcel->getactivesheet ()->setcellvalue (' D2 ', ' world! '); $objPHPExcel->getactivesheet ()->settitle (' simple '); $objPHPExcel->setactivesheetindex (0); $objWriter = Phpexcel_iofactory::createwriter ($objPHPExcel, ' Excel2007 ');//The following is saved//the following two sentences are saved directly to the current directory $outputfilename = "   Output.xlsx "; $objWriter->save ($outputFileName);//And I want to prompt the user to choose the path before saving, the following method is used (from the Internet), but he directly output to the browser, no prompt to save the header ("   Content-type:application/force-download ");   Header (' Content-disposition:inline;filename= '. $outputFileName. ' ');   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--------------------
Help the top!
------Solution--------------------
PHP Code
Header ("Pragma:public"), Header ("expires:0"), Header ("Cache-control:must-revalidate, Post-check=0, pre-check=0"); Header ("Content-type:application/force-download"); Header ("Content-type:application/download"); Header (" Content-disposition:attachment;filename= $outputFileName "); Header (" Content-transfer-encoding:binary ");
------Solution--------------------
This is the main sentence.
Header (' Content-disposition:inline;filename= '. $outputFileName. ' ');
Change
Header ("Content-disposition:attachment;filename= $outputFileName");
------Solution--------------------
No problem, your original code will be able to

Just the second row is wrong.
Set_include_path (Get_include_path (). Path_separator. Lib_dir. Directory_separator. " Phpexcel ". Directory_separator. " Classes ");
Change it to the bottom.
Set_include_path (Get_include_path (). Path_separator. Lib_dir. Directory_separator. " Phpexcel ". Directory_separator. " Classes ");

------Solution--------------------
Top
------Solution--------------------
Help the top.
  • 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.