Conditional formatting set to color red shows as green

Topics: Developer Forum
Feb 5, 2014 at 9:22 PM
I am using PHPExcel 1.7.9 and I used the test code in the examples to make my conditional formatting work. The only problem I have is that instead of RED it shows as GREEN... Since this is negative numbers... this poses a problem.

Here's my code for the formatting.
// Negative numbers are red
$objConditional2 = new PHPExcel_Style_Conditional();
$objConditional2->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS)
    ->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_LESSTHAN)
    ->addCondition('0');
$objConditional2->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_RED);
$objConditional2->getStyle()->getFont()->setItalic(true);

$conditionalStyles = $objPHPExcel->getActiveSheet()->getStyle("{$costColumn}2")->getConditionalStyles();
array_push($conditionalStyles, $objConditional2);
$editableSheet->getStyle("{$costColumn}2")->setConditionalStyles($conditionalStyles);
$objPHPExcel->getActiveSheet()->duplicateConditionalStyle(
    $objPHPExcel->getActiveSheet()->getStyle("{$costColumn}2")->getConditionalStyles(),
    "{$costColumn}2:{$profitPercentageColumn}{$lineNumber}"
);
I do have this code above the conditional formatting in case it helps:
// Apply formats
$editableSheet->getStyle("{$costColumn}2:{$priceColumn}{$lineNumber}")
    ->getNumberFormat()
    ->setFormatCode('$#,##0.000_-')
;
$editableSheet->getStyle("{$qtyShpColumn}2:{$qtyShpColumn}{$lineNumber}")
    ->getNumberFormat()
    ->setFormatCode('#,##0_-')
;
$editableSheet->getStyle("{$extPriceColumn}2:{$extPriceColumn}{$lineNumber}")
    ->getNumberFormat()
    ->setFormatCode('$#,##0.000_-')
;
$editableSheet->getStyle("{$profitPercentageColumn}2:{$profitPercentageColumn}{$lineNumber}")
    ->getNumberFormat()
    ->applyFromArray(
        array(
            'code' => PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00
        )
    )
;
Everything works as expected but the color for the conditional formatting shows as green... I only want red on negative.

Thanks for any input.
Jeremy