셀 캐싱을 위해 PHPExcel 1.7.8 매뉴얼의 모든 메소드를 사용해 보았지만 아무 것도 작동하지 않았습니다. 30MB 정도의 Excel 파일을로드하려고 할 때마다 메모리가 부족합니다.PHPExcel에서 셀 캐싱을 사용할 수 없습니다.
ini_set('memory_limit', '256M'); // Up from default 32MB
require MODULES_DIR . '/PHPExcel.php';
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_discISAM;
$cacheSettings = array('dir' => '/usr/local/tmp');
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
$inputFileType = PHPExcel_IOFactory::identify($dir . $source_file);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load($dir . $source_file);
$total_sheets = $objPHPExcel->getSheetCount();
$allSheetName = $objPHPExcel->getSheetNames();
$objWorksheet = $objPHPExcel->setActiveSheetIndex(0);
$highestRow = $objWorksheet->getHighestRow();
$highestColumn = $objWorksheet->getHighestColumn();
$headingsArray = $objWorksheet->rangeToArray('A1:'.$highestColumn.'1',null, true, true, true);
$headingsArray = $headingsArray[1];
$r = -1;
$namedDataArray = array();
for ($row = 2; $row <= $highestRow; ++$row) {
$dataRow = $objWorksheet->rangeToArray('A'.$row.':'.$highestColumn.$row,null, true, true, true);
if ((isset($dataRow[$row]['A'])) && ($dataRow[$row]['A'] > '')) {
++$r;
foreach($headingsArray as $columnKey => $columnHeading) {
$namedDataArray[$r][$columnHeading] = $dataRow[$row][$columnKey];
}
}
}
나는 모든 방법 "cache_to_sqlite3"에 이르기까지 셀 캐싱 메커니즘을 모두 시도했지만 그들 중 누구도 작동하지 :
여기 내 코드입니다.
누군가 내가 여기서 잘못하고있는 것을 말해 줄 수 있습니까?
편집 : 분명히 "cache_to_sqlite"옵션을 건너 뜁니다. 나는 그것을 시도하고 그것은 캐싱을 시작했다. 그러나 사용 가능한 메모리가 256MB 인 30MB 파일의 캐싱 프로세스 중에 여전히 메모리가 부족합니다. 여기에 오류가 있습니다 :
Fatal error: Uncaught exception 'Exception' with message 'out of memory' in modules/PHPExcel/CachedObjectStorage/SQLite.php:64 Stack trace: #0 modules/PHPExcel/CachedObjectStorage/SQLite.php(81): PHPExcel_CachedObjectStorage_SQLite->_storeData() #1 modules/PHPExcel/Worksheet.php(1123): PHPExcel_CachedObjectStorage_SQLite->addCacheData('X2498702', Object(PHPExcel_Cell)) #2 modules/PHPExcel/Reader/Excel5.php(3549): PHPExcel_Worksheet->getCell('X2498702') #3 modules/PHPExcel/Reader/Excel5.php(894): PHPExcel_Reader_Excel5->_readLabelSst() #4 modules/updater.inc.php(1478): PHPExcel_Reader_Excel5->load('modules/p...') #5 modules/updater.php(204): Updater->process_xls('prods.xls') #6 {main} thrown in modules/PHPExcel/CachedObjectStorage/SQLite.php on line 64
안녕하세요! 공개적으로 표시되지 않는 한 파일을 업로드해도 문제가 없습니다. phpexcel.net 웹 사이트 어디에서 업로드합니까? – eComEvo
이메일을 보냈습니다. 당신이 그것을 얻지 않고 큰 시간을 가져 주시면 알려주세요! :) – eComEvo