PHPExcel 未在服务器中导入 Excel 工作表

标签 php linux ubuntu amazon-ec2

我正在尝试使用 PHPExcel 从 Excel 工作表导入数据

我的代码行是

$cacheMethod = PHPExcel_CachedObjectStorageFactory:: cache_to_phpTemp;
$cacheSettings = array('memoryCacheSize' => '5120MB');    
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);

早些时候在我的本地我曾经遇到过这个错误:

Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y bytes)

我将 php.ini 文件中的内存大小从 128M 增加到 256M,并且此功能在我的本地运行良好。所以我在我的服务器上做了同样的事情,但它不起作用。我正在使用 Ubuntu 服务器。

最佳答案

$cacheMethod = PHPExcel_CachedObjectStorageFactory:: cache_to_phpTemp;
$cacheSettings = array('memoryCacheSize' => '5120MB');
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);

这告诉 PHPExcel 在开始使用 php://temp 进行单元格缓存之前使用 5GB (5120MB) 物理内存

您在 memoryCacheSize 设置中指定的任何值都应低于 PHP 可用的物理内存量

关于PHPExcel 未在服务器中导入 Excel 工作表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21997581/

相关文章:

php - ffmpeg视频编码策略防止低质量视频出现 "inflating"

angularjs - NoSuchWindowError : Browsing context has been discarded with GeckoDriver Firefox and Protractor(Selenium) 错误

java - 从java类在ubuntu中执行sudo命令

linux - Ubuntu 上的应用切换器中缺少 VSCode 图标

php - 为什么 Apache 打印我的 PHP 文件的内容而不是将它们传递给 PHP-FPM?

php - Laravel 5.2 无法打开 laravel.log

javascript - Nativescript http php 请求

linux - 读取 entropy_avail 文件似乎会消耗熵

linux - 什么会破坏/proc/self/exe?

c# - 请求特权并在 Ubuntu Linux 中使用 C# 保留此权限