views:

145

answers:

4

I'm writing a Cocoa application and I'm trying to export to the Excel XML format (ISO/IEC 29500-1) which is basically a zip file with a bunch of xml files in it named with a .xlsx extension.

I've tried generating apple script and using NSAppleScript to create the Excel file, which works, but is slow and the user has to have Excel installed on their machine.

I was able to create a simple .xlsx Excel file by writing the xml to files in objective-c and zipping them up and re-naming the zip to .xlsx. Excel could open the file, but Numbers threw an error trying to open the file I created. It seems Excel must have implemented all (or most of) the ISO/IEC spec, while Numbers may only open the Excel flavored version.

Are there any examples of how to do this using cocoa/objective-c or a library that would help simplify this task?

A: 

Don't know about any objective-c library, but the holy wiki offers some links to libraries, which would probably give you a good start: http://en.wikipedia.org/wiki/List_of_software_that_supports_Office_Open_XML#Programmatic_support_2 If the Office Open Xml format isn't a requirement, and you don't need overly complex files exported, I also suggest checking saving the files as stylesheet formatted html which excel can also read. A simple way to learn how to format the html you want as a spreadsheet is creating the file in excel, and saving it as HTML.

Amitay Dobo
+1  A: 

I've worked with the OpenOffice api and it works great. I would suggest you work with that to create your excel files. If you dont have time time/patience to do that, a workaround could be to have 2 links to export files, the XLSX version hack for the excels of the world and then a separate exported .csv file for the Numbers application.

JiminyCricket
A: 

You could check out the MSDN documentation of the XLSX file format. May that is of help to you...

froeschli
A: 

Try something like this:

http://www.artofsolving.com/opensource/pyodconverter

its a wrapper for open office written in python which provides a command line conversion.

Duncan