setOffice2003Compatibility missunderstood?

Topics: Developer Forum, User Forum
Aug 26, 2009 at 6:01 PM

My client only has Excel 2003, so I thought I could use setOffice2003Compatibility to dumb down my 2007 file a bit. I was having issues, so I created this simple test:

$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0)
            ->setCellValue('A1', 'test');

$objPHPExcel->getActiveSheet()->setTitle('Simple');
$objPHPExcel->setActiveSheetIndex(0);

$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->setOffice2003Compatibility(true);
$objWriter->save("report.xls");

It creates the file just fine, but when you try and open the file in Excel 2003 I get the error message " This file is not in a recognizable format."  If I open it anyway, it's all jiberish. When I open the same file in 2007 I get the following message: "The file you are trying to open is in a different format than specified by the file extension..." however if I open it it's as expected. I'm I totally miss understanding how this works?

thanks

summer

 

Developer
Aug 26, 2009 at 6:46 PM
  • PHPExcel_Writer_Excel2007 is only for creating xlsx files.
  • PHPExcel_Writer_Excel5 is only for creating xls files.

Your client has Microsoft Office Excel 2003. If he has installed the "Microsoft Office Compatibility Pack for Word, Excel, and PowerPoint 2007 File Formats" on top of his Microsoft Office Excel 2003 he should be able to open and save xlsx files. In this situation you may decide to create xlsx files using PHPExcel_Writer_Excel2007, optionally with the setOffice2003Compatibility(true) flag to solve certain problems with formulas, in any case you are creating xlsx files here.

If he has not installed the compatibility pack, he will only be able to open and save xls files. You need to use PHPExcel_Writer_Excel5 in this situation.

Sep 1, 2009 at 10:22 PM
Edited Sep 1, 2009 at 10:31 PM

Perfect. Thanks, I had misunderstood. I get it now.

Can you confirm that the conditional formatting feature does not work when saving files via PHPExcel_Writer_Excel5?

Developer
Sep 1, 2009 at 10:37 PM

>> Can you confirm that the conditional formatting feature does not work when saving files via PHPExcel_Writer_Excel5

Yes, I can confirm that. This feature has not yet been implemented in PHPExcel_Writer_Excel5.