php - PHPExcel insert array formula -


i want insert array formula:

{=sum(if(frequency(if(t9:t977=1,match(u9:u977,u9:u977,0)),row(u9:u977)-row(u9)+1),1))} 

but when i'm using:

$sheet->getcell("c1")->setvalue("{=sum(if(frequency(if(t9:t977=1,match(u9:u977,u9:u977,0)),row(u9:u977)-row(u9)+1),1))}"); 

it doesn't work, i've checked documentation, still haven't found anything.

i couldn't find answer went through phpexcel , made myself solution:

in /phpexcel/cell.php @ row 251 in switch($pdatatype) add this:

case phpexcel_cell_datatype::type_formula_array: $this->_value = (string)$pvalue; break; 

in /phpexcel/cell/datatype.php add constant:

const type_formula_array = 't'; 

at last in /phpexcel/writer/excel2007/worksheet.phpi've added in switch beginning @ row 1095:

case 't':           // array formulae     $objwriter->startelement('f');     $objwriter->writeattribute('t', 'array');     $objwriter->writeattribute('ref', $pcelladdress);     $objwriter->writeattribute('aca', '1');     $objwriter->writeattribute('ca', '1');     $objwriter->text($cellvalue);     $objwriter->endelement();                    if ($this->getparentwriter()->getoffice2003compatibility() === false) {         if ($this->getparentwriter()->getprecalculateformulas()) {             $calculatedvalue = $pcell->getcalculatedvalue();             if (!is_array($calculatedvalue) && substr($calculatedvalue, 0, 1) != '#') {                 $objwriter->writeelement('v', phpexcel_shared_string::formatnumber($calculatedvalue));             } else {                 $objwriter->writeelement('v', '0');             }         } else {             $objwriter->writeelement('v', '0');     } } break; 

then used function this:

$sheet->getcell("c1")->setvalueexplicit("=sum(if(frequency(if(t9:t977=1,match(u9:u977,u9:u977,0)),row(u9:u977)-row(u9)+1),1))", phpexcel_cell_datatype::type_formula_array); 

and works when i'm creating excel file!


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -