How do I select a path when saving in PHPExcel? How can I select the storage path for exporting Excel using PHPExcel ?? PHPcodeset_include_path (get_include_path (). PATH_SEPARATOR.LIB_DIR.DIRECTORY_SEPARAT how to select a path when saving in PHPExcel?
How can I select the storage path for exporting Excel using PHPExcel ??
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 2007 XLSX T Est Document "); $ objPHPExcel-> getProperties ()-> setSubject (" Office 2007 XLSX Test Document "); $ objPHPExcel-> getProperties () -> setDescription ("Test document for Office 2007 XLSX, generated using PHP classes. "); $ objPHPExcel-> getProperties ()-> setKeywords (" office 2007 openxml php "); $ objPHPExcel-> getProperties ()-> setCategory (" Test result file "); $ objPHPExcel-> setActiveSheetIndex (0); $ objPHPExcel-> getActiveSh Eet ()-> 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 '); // save the following two sentences to the current directory: $ outputFileName = "output.xlsx"; $ objWriter-> save ($ outputFileName ); // if I want to prompt the user to select the path before saving the file, I will use the following method (from the Internet), but he will output it directly to the browser, you are not prompted to save the header ("Content-Type: application/force-download"); header ('content-Disposition: inline; filename = "'. $ outputFileName. '"'); 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 ');
------ Solution --------------------
Help!
------ 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 sentence
Header ('content-Disposition: inline; filename = "'. $ outputFileName .'"');
Change
Header ("Content-Disposition: attachment; filename = $ outputFileName ");
------ Solution --------------------
No problem. you can use the original code.
An error occurred in the second line.
Set_include_path (get_include_path (). PATH_SEPARATOR. LIB_DIR.DIRECTORY_SEPARATOR. "PHPExcel". DIRECTORY_SEPARATOR. "Classes ");
Change it to the following.
// Set_include_path (get_include_path (). PATH_SEPARATOR. LIB_DIR.DIRECTORY_SEPARATOR. "PHPExcel". DIRECTORY_SEPARATOR. "Classes ");
------ Solution --------------------
Top
------ Solution --------------------
Help