如何在Laravel 4.2上configuration和使用Box Spout

我需要在Laravel 4.2上configuration和使用Box Spout,但是,库不起作用。 我运行命令来安装Composer依赖关系:

composer require box/spout 

但是,代码不起作用:

 $writer = WriterFactory::create(Type::XLSX); // for XLSX files $filePath = public_path() . "/relatorios/test.xlsx"; $writer->openToFile($filePath); $singleRow = ['No'=>1,'Nama'=>'Bayummic','Nilai'=>11,'Nim'=>14140101]; $writer->addRow($singleRow); // add a row at a time $writer->close(); 

错误信息:

 [2016-12-07 17:35:38] production.INFO: D:\Projetos\Testes\LaravelQueues\public [] [] [2016-12-07 17:35:38] production.ERROR: exception 'Box\Spout\Common\Exception\IOException' with message 'Cannot perform I/O operation outside of the base folder: C:\Windows\Temp' in D:\Projetos\Testes\LaravelQueues\vendor\box\spout\src\Spout\Common\Helper\FileSystemHelper.php:130 

感谢收听。

在创buildXLSX文件的默认临时文件夹似乎有问题。 你可以尝试使用$writer->setTempFolder('PATH/TO/CUSTOM/TEMP/FOLDER'); 在调用openToFile()来覆盖默认位置之前。