BalaChandra
BalaChandra

Reputation: 652

Parsing excel files in iOS

In my ios application i am trying to parse the excel file given by the user and do something with the data later on.. which i dint decided yet.. I have searched about how to parse excel file in iOS, and find that many are saying convert the excel file to csv file and parse that, i also find a framework DHlibxls and tried using it, after cloning it from github, it has also given a test project on how to parse excel files and it is also working fine, but the problem is in that test project i tried to replace the existing test.xls file with another test file then after i tried to run it gave an exception and the app crashed.enter image description here

the new file i added is .xlsx file, so i thought that may be it wont read the .xlsx file , so then i tried to add a small .xls file but still the exception occured, after that i tried to add the same test file given in the folder but by changing the name to test2.xls, but the exception is still there. I cant understand the problem.

Many are saying that convert the .xls file to .csv file, how to convert it in ios , is there a library or method in ios to convert the .xls file to .csv dynamically while the app is running..Thank you

Upvotes: 0

Views: 3203

Answers (3)

shirish
shirish

Reputation: 11

but it take too much time read data in xlsx.

Upvotes: -1

Ucdemir
Ucdemir

Reputation: 3098

You can use XlsxReaderWriter library...It is free and usefull for read & write!

  • Create a new project or open an existing project
  • Insert XlsxReaderWriter.xcodeproj as a sub project of your project
  • In your target Build phases insert XlsxReaderWriter as a target dependency
  • Add libXlsxReaderWriter.a and libz.tbd in Link binary with Libraries. Older systems can use libz.dylib instead of libz.tbd.
  • Add -all_load in Linking / Other Linker Flags in your project settings
  • Add the XlsxReaderWriter root directory path to User Header Search Paths and set it as recursive. For example, set the path to "$(SRCROOT)/XlsxReaderWriter/", not "$(SRCROOT)/XlsxReaderWriter/XlsxReaderWriter/".

Now, you can import BRAOfficeDocumentPackage.h in your code.

It also supports Swift:

Upvotes: 1

Inder Kumar Rathore
Inder Kumar Rathore

Reputation: 39988

While adding a file make sure that it's membership is checked as in the below screen.

enter image description here

Or for existing files in xcode do the following to add it in the target. Select the file and check the file inspector and then check the target membership.

enter image description here

Upvotes: 1

Related Questions