PhpExcel将文件保存到文件夹

时间:2014-03-21 13:17:20

标签: php codeigniter phpexcel

我想将生成的文件保存到服务器中的文件夹中,我尝试了以下代码:

//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');

但我一直收到以下错误:

  

遇到PHP错误

     

严重性:警告

     

消息:fopen(-C:\ xampp \ htdocs \ timesheet \ files \ trials.xls):失败   打开流:无效的参数

     

文件名:PPS / Root.php

     

行号:90

     

致命错误:未捕获异常'PHPExcel_Writer_Exception'   消息'无法打开'C:\ xampp \ htdocs \ timesheet \ files \ trials.xls。它   可能正在使用或受到保护。在   C:\ XAMPP \ htdocs中\时间表\应用\ THIRD_PARTY \ PHPExcel \共享\ OLE \ PPS \ Root.php:93   堆栈跟踪:#0   C:\ XAMPP \ htdocs中\时间表\应用\ THIRD_PARTY \ PHPExcel \作家\ Excel5.php(226):   PHPExcel_Shared_OLE_PPS_Root-> save('??? C:\ xampp \ htd ...')#1   C:\ XAMPP \ htdocs中\时间表\应用\控制器\ time_sheet.php(6130):   PHPExcel_Writer_Excel5-> save('??? C:\ xampp \ htd ...')#2 [内部   功能]:Time_sheet-> save_time_sheet()#3   C:\ XAMPP \ htdocs中\时间表\ SYSTEM \核心\ CodeIgniter.php(359):   call_user_func_array(Array,Array)#4   C:\ XAMPP \ htdocs中\时间表\的index.php(202):   require_once('C:\ xampp \ htdocs ...')#5 {main}引入   C:\ XAMPP \ htdocs中\时间表\应用\ THIRD_PARTY \ PHPExcel \共享\ OLE \ PPS \ Root.php   第93行

保存文档的最佳方法是什么?

0 个答案:

没有答案