How to remove existing conditional formatting?

Topics: Developer Forum, User Forum
Mar 6, 2013 at 1:25 PM
Edited Mar 6, 2013 at 1:26 PM
Using 1.7.8 in Apache running on WinXP.

The task is to read in a spreadsheet file, do some manipulation on the worksheet, and output the updated sheet. This works fine. But the input sheet has some cells with conditional formatting that I wish to remove before manipulating and sending back to the user.

The following is my current code to try to accomplish this task, but it does not remove the conditional formatting:
$condition_style = new PHPExcel_Style_Conditional();
$condition_style->setConditionType(PHPExcel_Style_Conditional::CONDITION_NONE);
$condition_style->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_NONE);
$condition_style->addCondition('');

for ($x=1; $x<=$totalrows; $x++) {
    for ($y=0; $y < $totalcols; $y++) {
         $worksheet1->getStyleByColumnAndRow($y,$x)->setConditionalStyles($condition_style);
    }
}
Any help and suggestions would be appreciated.

John
Mar 6, 2013 at 4:59 PM
Not played with this, but you have a method removeConditionalStyles($Coordinate) for the worksheet object.
Mar 18, 2013 at 3:20 PM
Thanks for that. I thought I had subscribed but I did not see this for 1-1/2 weeks.

This is just what I was looking for. And I created the ByRowAndColumn version as well. Works a treat.

Thanks again.