Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read data from Excel file in Objective-C (iPhone) [closed]

I've searched in google but I don't seem to find a way to read Excel files from Objective-C. The only answers I find are to first convert to CSV and then read as a text file, but I don't want that.

I know there must be a way, while I used many times the PHP modules to read/write Excel files, so I'm supposing there's also a C library to do that (which then could be used in Objective-C/iPhone app)

So ... does anyone know of such a library I could use on the iPhone?

like image 591
Marin Todorov Avatar asked Aug 18 '10 19:08

Marin Todorov


5 Answers

I think the PHP libraries use the Office OpenXML formats... The best library for reading/writing binary Excel files ( without running Excel itself and calling it via COM ) I've used is Apache POI - http://poi.apache.org/, but this is Java. You could attempt to use GCJ to get that working on the iPhone, but who knows what Apple would make of it. You could manually port the whole thing to Obj-C/ C++ I guess...

There are a few C / C++ libraries that do a limited subset, but they probably are not incredibly reliable or simple to use.

http://xlslib.sourceforge.net/index.php - LGPL

http://www.libxl.com/ - Commercial, $199, who knows if they would give you source for that to compile into your app.

http://www.codeproject.com/KB/office/ExcelFormat.aspx - C++ source, incredibly unclear licence like everything on code project. Who knows.

Another option is to attempt to extract the code from an open source excel reading competitor. Open Office - http://www.openoffice.org/ - is likely to be a complete nightmare, Gnumeric is probably a better bet. Excel code is here - http://git.gnome.org/browse/gnumeric/tree/plugins/excel - its likely to need a lot of messing about to make it work outside Gnumeric. KSpread has similar code here : http://websvn.kde.org/trunk/koffice/filters/kspread/excel/import/ , but I believe Gnumeric has a better reputation for accuracy wrt to Excel import.

like image 123
rjw Avatar answered Nov 16 '22 13:11

rjw


Actually, there is such a project - its called libxls on source forge. There is a ObjectiveC class interface to the project as well. With this project you can open an excel file, and read most of the information in it (cell values as well as the file's properties).

In addition there is an iOS Objective C interface to the library.

like image 24
David H Avatar answered Nov 16 '22 12:11

David H


@David H
I find his answer is the best to solve the problem. You will find his DHlibxls is better to analyzing the xls file in the ios program. Here is in my blog‘s summary

like image 2
Robot1987 Avatar answered Nov 16 '22 11:11

Robot1987


Other way, some where use libxls.

any way, more choose:

https://github.com/QuetzalMX/QuetzalXLSReader

like image 2
rbbtsn0w Avatar answered Nov 16 '22 11:11

rbbtsn0w


I recently got into a project where the client wanted to import information from an Excel file into an app. I know a lot of people say, just transform it into a CSV and parse it that way, but I really didn't want the client to go through yet another step and introduce a different file format - as simple as that may be.

I tried using DHlibxls, but I felt it was a little bit too complicated, so I created QZXLSReader. It's a drag-and-drop solution so it's a lot easier to use. I don't think it's as feature complete, but it worked for me.

It's basically a library that can open XLS files and parse them into Obj-C classes. Once you have the classes, it's very easy to send them to Core Data or a dictionary or what have you.

I hope it helps!

like image 1
olivaresF Avatar answered Nov 16 '22 11:11

olivaresF