problems with caching

Topics: Developer Forum
May 4, 2011 at 11:21 AM
Edited May 4, 2011 at 11:23 AM

Hi, 

I am trying to read a file with many sheets. 

I am trying to read one sheet at a time with:

$objReader->setLoadSheetsOnly($sheet);

and i am using caching

$cacheMethod = PHPExcel_CachedObjectStorageFactory:: cache_to_phpTemp; 
$cacheSettings = array( ' memoryCacheSize ' => '1024MB'); 
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings); $objReader = new PHPExcel_Reader_Excel2007();

but when i read the sheet and display its contents, some of the results come from a different sheet.
I am only calling one sheet.

is it the cache?

Thanks

on a windows 7 machine using Chrome and WAMP 

EDIT: I created a new file with only the sheet i am trying to read. When I read that file the data returned is 100% correct.

Coordinator
May 7, 2011 at 9:16 PM

If you're not unsetting each sheet before reading the next, then this could cause problems (though it's not related to caching specifically).

Because PHP cannot handle cleanly unsetting the PHPExcel object automatically, because of cyclic references within the structure of the objects, there is a special method designed to clean these references up before unsetting the object manually using:

$objPHPExcel->disconnectWorksheets();
unset($objPHPExcel);

after you've finished processing the current PHPExcel object in your loop.