Rich Text Format Issue with Excel5 and phpexcel 1.7.7

Topics: Developer Forum, Project Management Forum, User Forum
Jun 18, 2012 at 9:42 PM

Im working on a project that needs to export data in different reports. Each report is defined in a xls template. My app takes that template, fills some data in it and exports it to another xls as well.

The main problem is that a lot of cells have multiple format like some characters being superscripted, another being in italic, greek symbols, etc.

I need to export the reports in xls Excel5 format. I tried it with Excel2007 to see the results and im glad to say that it works flawlessly. The problem is that i need to open the xls files in Excel2000. So Excel5 is a MUST for me.

With phpexcel 1.7.6 and Excel5 Reader and Writter most format got lost. The greek symbols were fine, but text that have part italic and part non italic came out all non-italic, ALL superscripted characters were lost, etc.

With the new phpexcel 1.7.7, that supports rich text for Excel5, Im a little bit close, but not quite. For one template it works almost fine, it keeps the format but changes the font color and some bold text appears non-bold. On the bright side, it keeps the superscripted characters that are very important since the reports are chemical-oriented.

The strange thing, is that with another template it outputs a broken xls. The same xls template that worked on 1.7.6, keeps coming broken on 1.7.7. I cant open it in Excel2000 nor 2003 nor mac excel 2010. It just comes broken. Im supposing that some data in that specific template is producing this phpexcel output. But the library doesnt throws any exception nor errors. The original xls opens fine, but the xls produced by phpexcel, that i just opened the original one and saved, it wont open.

For testing purposes, Im not even filling the data that im supposed to fill, Im just reading and saving the template, since the formatted text that i want to keep in the output is the same as in the input.

Any help would be really appreaciated... im really frustrated :(

Thanks in advance!

Jun 18, 2012 at 9:49 PM

This is the code:

include sfConfig::get('sf_lib_dir') . '/excel/PHPExcel.php';
include sfConfig::get('sf_lib_dir').'/excel/PHPExcel/Writer/Excel5.php';

$objPHPExcel = PHPExcel_IOFactory::load($xlsBase);
$objPHPExcel->setActiveSheetIndex(0);

//fill in the data

//leave the xls in first page and 100 zoom
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->getSheetView()->setZoomScale(100);

$writer = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$writer->save($outputfullpathFileName);

Jun 18, 2012 at 10:18 PM

Here are the 2 main templates. The "SMS" one is the one that keeps coming out broken in phpexcel 1.7.7

 

https://www.dropbox.com/sh/c5y9hpk569w2ylp/wDEHywsQC2