PhpExcel Save file to a folder

可紊 提交于 2019-12-25 02:45:01

问题


I want to save the generated file to a folder located in the server, I tried the following code :

//save it to Excel5 format (excel 2003 .XLS file), change this to 'Excel2007' (and adjust the filename extension, also the header mime type)
//if you want to save it as .XLSX Excel 2007 format
        $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
//force user to download the Excel file without writing it to server's HD
        $objWriter->save('‪C:\xampp\htdocs\timesheet\files\trials.xls');

but I keep getting the following error :

A PHP Error was encountered

Severity: Warning

Message: fopen(‪C:\xampp\htdocs\timesheet\files\trials.xls): failed to open stream: Invalid argument

Filename: PPS/Root.php

Line Number: 90

Fatal error: Uncaught exception 'PHPExcel_Writer_Exception' with message 'Can't open ‪C:\xampp\htdocs\timesheet\files\trials.xls. It may be in use or protected.' in C:\xampp\htdocs\timesheet\application\third_party\PHPExcel\Shared\OLE\PPS\Root.php:93 Stack trace: #0 C:\xampp\htdocs\timesheet\application\third_party\PHPExcel\Writer\Excel5.php(226): PHPExcel_Shared_OLE_PPS_Root->save('???C:\xampp\htd...') #1 C:\xampp\htdocs\timesheet\application\controllers\time_sheet.php(6130): PHPExcel_Writer_Excel5->save('???C:\xampp\htd...') #2 [internal function]: Time_sheet->save_time_sheet() #3 C:\xampp\htdocs\timesheet\system\core\CodeIgniter.php(359): call_user_func_array(Array, Array) #4 C:\xampp\htdocs\timesheet\index.php(202): require_once('C:\xampp\htdocs...') #5 {main} thrown in C:\xampp\htdocs\timesheet\application\third_party\PHPExcel\Shared\OLE\PPS\Root.php on line 93

What is the best way to save the document?

来源:https://stackoverflow.com/questions/22559894/phpexcel-save-file-to-a-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!