PhpExcel将文件保存到文件夹

PhpExcel将文件保存到文件夹,php,codeigniter,phpexcel,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 = PHPEx

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

//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\u Writer\u exception”,带有 消息“无法打开”-C:\xampp\htdocs\timesheet\files\trials.xls。信息技术 可能正在使用或受到保护。'in C:\xampp\htdocs\timesheet\application\third\u party\PHPExcel\Shared\OLE\PPS\Root.php:93 堆栈跟踪:#0 C:\xampp\htdocs\timesheet\application\third\u party\PHPExcel\Writer\Excel5.php(226): PHPExcel_Shared_OLE_PPS_Root->save('???C:\xampp\htd…')1 C:\xampp\htdocs\timesheet\application\controllers\time\u sheet.php(6130): PHPExcel_Writer_Excel5->保存('???C:\xampp\htd…')#2[内部 功能]:时间表->保存时间表() C:\xampp\htdocs\timesheet\system\core\CodeIgniter.php(359): 调用_user_func_数组(数组,数组)#4 C:\xampp\htdocs\timesheet\index.php(202): 需要一次('C:\xampp\htdocs…')#5{main}抛出 C:\xampp\htdocs\timesheet\application\third\u party\PHPExcel\Shared\OLE\PPS\Root.php 在线93


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

那么你检查了文件/目录权限了吗?@MarkBaker是的,权限对所有用户都是完全控制的,我尝试了相同的方法,指向以下文件夹C:\users\user\Music\Playlists\trials.xls,但仍然得到相同的错误。错误很明显;PHP代码
fopen($filename,“wb”)
行返回了一个失败的结果(布尔值为false),这意味着无法打开/创建指定的文件名进行写入。不幸的是,PHP没有给出任何说明为什么会出现这种情况,但最常见的原因是文件权限、无效的文件路径或文件已被打开并被锁定