我需要在Laravel 4.2上配置和使用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
感谢收听。
答案 0 :(得分:1)
默认临时文件夹似乎有问题,其中创建了XLSX文件。您可以在调用$writer->setTempFolder('PATH/TO/CUSTOM/TEMP/FOLDER');
之前尝试使用openToFile()
覆盖默认位置。