Conditional formating and Office 2003 compatibility pack

Topics: Developer Forum, User Forum
Mar 5, 2009 at 4:45 PM
Hello,

I have a problem when I try to open a generated Excel 2007 file on Office 2003 with conditional formating. Excel said to me that my condiotionnal formating style isn't compatible with this version of Excel. I try to set the "setOffice2003Compatibilty" to true, but I have the same result.
Here the code :

$objPHPExcel = new PHPExcel();

$objPHPExcel->setActiveSheetIndex(0);

$conditional1 = new PHPExcel_Style_Conditional();
$conditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS);
$conditional1->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_EQUAL);
$conditional1->addCondition(10);
$conditional1->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_YELLOW);
$conditional1->getStyle()->getFont()->setBold(true);

$objPHPExcel->getActiveSheet()->getStyle('A1')->setConditionalStyles(array($conditional1));

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->setOffice2003Compatibility(true);
$objWriter->save('test.xlsx');

Another thing : I have created a Excel file in Excel with the same conditional formatting and I have saved it to a .xlsx file and that's work...
I have found a difference between the generated and the created file in the style.xml file
Generated file :
<dxf>
   <font>
    <name val="Calibri"/>
    <sz val="10"/>
    <b val="true"/>
    <u val="none"/>
    <color rgb="FFFFFF00"/>
   </font>
   <numFmt numFmtId="164" formatCode="General"/>
   <fill>
    <patternFill patternType="none">
     <fgColor rgb="FFFFFFFF"/>
     <bgColor rgb="FF000000"/>
    </patternFill>
   </fill>
   <alignment horizontal="general" vertical="bottom" textRotation="0"/>
   <border outline="true"/>
  </dxf>

Created file :
<dxf>
  <font>
    <b/>
    <i val="0"/>
    <condense val="0"/>
    <extend val="0"/>
    <color indexed="13"/>
    </font>
</dxf>

I try to copy-paste the tags from created file to generated file with no success.

How to resolve this problem (if it is possible to resolve it) ?

Thank



Developer
Mar 5, 2009 at 11:36 PM
We will need Maarten to look at this!