PhpExcel how to pass parameters to a class

Basically, I'm trying to enable cell caching due to memory issues (keeps running out of) its a pretty big speech line. From what I've read online caching is a good way to go

From examples I found on the internet, it looks something like this.

Cell Caching and Memory Leaks

stack overflow

$oExcel = new PHPExcel();
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
$cacheSettings = array( 'memoryCacheSize' => '512MB');

PHPExcel_Settings::setCacheStorageMethod($cacheMethod,$cacheSettings);

      

The problem with the above is im not setting the excel object with settings?

$oExcel->setCacheStorageMethod($cacheMethod,$cacheSettings); // this returns method not found error

      

I think they are just not initializing this wrong?

+3


source to share


2 answers


It is described in section 4.2.1 of the developer's documentation: section "Caching cells"; and you need to set the cell cache before in order to instantiate or load the PHPExcel object.

setCacheStorageMethod () is not a method of the PHPExcel class as you are trying to use on this line:

$oExcel->setCacheStorageMethod($cacheMethod,$cacheSettings); 

      



using

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

$oExcel = new PHPExcel();

      

and the new PHPExcel object will automatically use the configured cache setting (i.e. phptemp)

+8


source


You can find a similar question here with a fairly extensive answer that includes a working example setCacheStorageMethod. Hope this helps!



+2


source







All Articles