SUMIF problem

Topics: Developer Forum
Dec 30, 2010 at 9:10 AM
Edited Dec 30, 2010 at 9:11 AM

Hi (merry xmas and happy new year)

I am having a problem wiht SUMIF

i am using this

$objPHPExcel->getActiveSheet()->setCellValue('E8', '=SUMIF($C$2:$C$5;"11";$B$2:$B$5)');

But it gives and error

Fatal error: Uncaught exception 'Exception' with message 'Formulas!E8 -> Formula Error: An unexpected error occured' in C:\wamp\www\phpexcel\Classes\PHPExcel\Cell.php:284 Stack trace: #0 C:\wamp\www\phpexcel\Classes\PHPExcel\Writer\Excel2007\Worksheet.php(965): PHPExcel_Cell->getCalculatedValue() #1 C:\wamp\www\phpexcel\Classes\PHPExcel\Writer\Excel2007\Worksheet.php(911): PHPExcel_Writer_Excel2007_Worksheet->_writeCell(Object(PHPExcel_Shared_XMLWriter), Object(PHPExcel_Worksheet), 'E8', Array, Array) #2 C:\wamp\www\phpexcel\Classes\PHPExcel\Writer\Excel2007\Worksheet.php(82): PHPExcel_Writer_Excel2007_Worksheet->_writeSheetData(Object(PHPExcel_Shared_XMLWriter), Object(PHPExcel_Worksheet), Array) #3 C:\wamp\www\phpexcel\Classes\PHPExcel\Writer\Excel2007.php(264): PHPExcel_Writer_Excel2007_Worksheet->writeWorksheet(Object(PHPExcel_Worksheet), Array) #4 C:\wamp\www\phpexcel\Tests\03formulastest.php(89): PHPExcel_Writer_Excel2007->save('C:\wamp\www\php...') #5 {main} thrown in C:\wamp\www\phpexcel\Classes\PHPExcel\Cell.php on line 284

i also tried
$objPHPExcel->getActiveSheet()->setCellValue('E8', '=SUMIF(C2:C5;"11";B2:B5)');   // without $s
but i get the same error

using version    1.7.5, 2010-12-10

Any ideas?

 

thanks in advance 

Coordinator
Dec 30, 2010 at 9:21 AM
Edited Dec 30, 2010 at 9:22 AM

Unless you've set the calculation engine to use locale settings, then PHPExcel recognises the en_us comma argument separator (,) rather than the semi-colon (;) argument separator.

$objPHPExcel->getActiveSheet()->setCellValue('E8', '=SUMIF($C$2:$C$5,"11",$B$2:$B$5)');
Dec 30, 2010 at 12:26 PM

awesome, 

it works now. thansk a lot