phpexcel - Excel sheet corrupted after conditional formatting -
i generating excel sheet phpexcel, when using conditional formatting condition being (search text or part of it), validation error when trying open generated sheet. works numbers, less texts.
here code :
//conditional formatting $objconditional1 = new phpexcel_style_conditional(); $objconditional1->setconditiontype(phpexcel_style_conditional::condition_containstext) ->setoperatortype(phpexcel_style_conditional::operator_containstext) ->addcondition('x'); $objconditional1->getstyle()->getfont()->getcolor()->setargb(phpexcel_style_color::color_yellow); $objconditional3 = new phpexcel_style_conditional(); $objconditional3->setconditiontype(phpexcel_style_conditional::condition_cellis) ->setoperatortype(phpexcel_style_conditional::operator_greaterthanorequal) ->addcondition('0'); $objconditional3->getstyle()->getfont()->getcolor()->setargb(phpexcel_style_color::color_green); $conditionalstyles = $objphpexcel->getactivesheet()->getstyle('b2')->getconditionalstyles(); array_push($conditionalstyles, $objconditional3); array_push($conditionalstyles, $objconditional1); $objphpexcel->getactivesheet()->getstyle('b2')->setconditionalstyles($conditionalstyles);
does 1 know how work around ? doing wrong ? thanks.
as far know, though have not tested case specifically, when try apply conditional formatting based on containstext, shouldn't call
'->addcondition('x')'
(line 5 in code), instead call method:
->settext('x')
on phpexcel_style_conditional objects. how specify text compare in phpexcel sheets.
Comments
Post a Comment