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.