Reading Multiple Files

Topics: Developer Forum, Project Management Forum, User Forum
Jul 4, 2012 at 2:45 PM

I'm using PHPExcel to read multiple excel files with identical structure.

After the first file has been loaded, the second file is loaded but the values retrieved with 

$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,false);

returns some values of the first opened file.

Here the code:

foreach($Mails as $Files)
{
	$DataEXCEL=array();       
	$objPHPExcel = PHPExcel_IOFactory::load($Files);
	$DataEXCEL = $objPHPExcel->getActiveSheet()->toArray(null,true,true,false);
	
	....
	
	unset($objPHPExcel);
}	
I Appreciate your help on this

 


Jul 4, 2012 at 3:17 PM

Solved !!!!

Adding this line: 

PHPExcel_Calculation::getInstance()->clearCalculationCache(); 

 

foreach($Mails as $Files)
{
	$DataEXCEL=array();       
	$objPHPExcel = PHPExcel_IOFactory::load($Files);
	$DataEXCEL = $objPHPExcel->getActiveSheet()->toArray(null,true,true,false);
	
	....
	
        PHPExcel_Calculation::getInstance()->clearCalculationCache(); 

	unset($objPHPExcel);
}

More Info:

http://phpexcel.codeplex.com/discussions/219330