1

Recently for a project i'm working, on i'm stuck between a rock and a hard place. On one hand i have a third party component that gives me a certain report in .xls format. This conponent is not controlled by me, so stays this way.

On the other hand i have a ods parser that parses all the data into mysql. This also cannot be changed as i need the file to actually be ods for further manipulation. Plus it was requested this way by the party that commissioned the project.

Is there a way to convert xls into ods with php? Maybe with another step in the middle. Perhaps XML or anything of the like? This all runs on LAMP so frankly i would not even mind some command line tool to

sid405
  • 63
  • 7
  • You might take a look at [php-spreadsheetreader](http://code.google.com/p/php-spreadsheetreader/) if the xls is in a pre-office 2007 format. If you're dealing with the newer excel format ... well that's already XML, so it should be relatively straightforward to use DOM or SimpleXML to read the data and spit it back out in the ODS format. –  Feb 04 '12 at 03:13

1 Answers1

0

The Open Office alternative to COM, called PUNO, is the first option that springs to mind. Effectively, it gives you an interface to a copy of OO itself that needs to be running on your LAMP stack. Calc can read xls, and then "save as" ods.

A second option would be using Ilia Alshanetsky's Excel extension, which is a wrapper around the commercial libxl library (cost about $199).

It won't be an option for PHPExcel until sometime around Q2 2012, though it is on the development roadmap. None of the other PHP Spreadsheet reader/writer libraries offer the ability to write non-Excel formats from Excel document; so if you used any of the existing reader libraries, you'd need to "roll your own" writer.

Community
  • 1
  • 1
Mark Baker
  • 209,507
  • 32
  • 346
  • 385