don't know how to write in ods file

Topics: User Forum
Jan 12, 2015 at 11:48 AM
Hi, i'd like to know what changes shall i do to write an ods(libreoffice) file,what are the changes between writing a xlsx file from an ods one?
when reading you should change the class to Reader/OOCalc.php and $objReader = new PHPExcel_Reader_OOCalc(); For writing, hou should it be? writing a xlsx file is:
$objWriter = PHPExcel_IOFactory::createWriter($data, 'Excel2007');
If i use that, it writes a file but when manually opening it it says:
" The file "name.ods" is damaged and can not be opened. LibreOffice can try to repair the file.

The damage may occur as a result of manipulation of the document or incomplete data transmission."
Any help would be grateful.
Jan 12, 2015 at 12:14 PM
The difference is selecting the correct Writer for the filetype that you are trying to generate:
$objWriter = PHPExcel_IOFactory::createWriter($data, 'OpenDocument');
Strictly speaking, this should be OOCalc like the Reader, and I'll make them consistent before the 1.8.1 release (OOCalc has become something of a misnomer since the release of LibreOffice), but for the moment it's OpenDocument.... for version 2, I'll probably change both to OASIS or possible ODS, which are more generic
Marked as answer by andnune on 1/12/2015 at 6:53 AM
Jan 12, 2015 at 2:19 PM
Edited Jan 12, 2015 at 2:20 PM
After changing to "OpenDocument" with $data = new PHPExcel(); it throws this error:

PHP Fatal error: Class 'PHPExcel_Writer_OpenDocument' not found in /my/server/Classes/PHPExcel/IOFactory.php on line 141
I'm using 1.8.0 release
Jan 12, 2015 at 2:47 PM
The 1.8.0 release doesn't support writing to .ods (OASIS-format) files. This is in the develop branch on github, but hasn't yet been included in a production release
Jan 12, 2015 at 2:54 PM
Ok, i've already changed the library and it works fine. Thank you!!