Does writing to Excel2007 work correctly in version 1.7.8? Excel2010 support?

Topics: Developer Forum
Dec 19, 2012 at 6:14 PM

Hi, I'm new to PHPExcel having only switched to using it yesterday as I need to read and write from various spreadsheet formats (ods,xls,xlsx) but whilst reading files appears to be fine I am finding that writing to files just doesn't work correctly outside of the tests (though they may also be wrong).

The problems I am having are that the worksheets are being created in the opposite order to that in which they were created. Only rows which have no data are being created OR data is only written to some of the worksheets (I have an excel file with 9 sheets, though I have also tested with a document with three sheets and only data on one of them).

The documents also appear to be created as right-to-left even though that option is not set.

What I am trying to achieve is the a script which reads an xlxs file (preferably only reading a limited number of sheets and a limited number of rows per sheet, so using setReadDataOnly, setLoadSheetsOnly and setReadFilter()), adds content into new cells onto some of the worksheets and then saves the file again.

However, to test the problem I created a new set of spreadsheets (Excel2010 (xlsx), Excell2003 (xml) and Excel5 compatible) and with the first sheet having cells A1 and B2 with data in them.

I then used this to test the script for "Excel2007" and Excel5 (changing the reader each time).

$excel2 = PHPExcel_IOFactory::createReader('Excel5');
$excel2 = $excel2->load($filename); // Empty Sheet
$excel2->getActiveSheet()->setCellValue('C6', '4')
    ->setCellValue('C7', '5')
    ->setCellValue('C8', '6')
    ->setCellValue('C9', '7');

$excel2->getActiveSheet()->setCellValue('A7', '4')
    ->setCellValue('C7', '5');
$objWriter = PHPExcel_IOFactory::createWriter($excel2, 'Excel5');

This one (above) worked fine for the Excel5 file. But when I tried it with the .xlsx (Excel2010) version it breaks. It creates the sheets right-to-left, with the first cell being on B3 (so the first two rows which had data are done) and the view is focused on cells AND3 through AML3. The three worksheets are also created in reverse order.

Before I move onto a different excel writer has anyone got this to actual work? 

PHPExcel Version 1.7.8

I'm running PHP 5.4.3