Home > Mobile >  How to use excel file data in an ios app?
How to use excel file data in an ios app?

Time:05-19

I'm new to Rad Studio so I may be missing something, but I am trying to create an iOS app that just displays a list of data. I currently have an iOS app with a tListView that gets populated by a ClientDataSet, which is populated with data that I hard-coded into an xml file that's on my PC. I want to be able to fill my ListView with the data that is in an excel file instead of xml file so that when I need to add an item I can just add it in the excel file on my PC and rebuild the project. Is this possible? The only way I have found to access excel file data is TADO Connection, but it seems you can not use it on iOS applications. Thank you in advance.

CodePudding user response:

I strongly recommend against using Excel files for this purpose. There are several reasons for that:

  1. Excel files are not designed to be sources of data for automated processing. These are electronic spreadsheets designed to be used by humans. Formats like XML, CSV and JSON work much, much better as data sources for programs.
  2. Excel file format is incredibly complex and requires that you ship a specialized library inside your app. This severely increases the binary size of your app and the download time, makes it start up slower and use more RAM.
  3. Decoding an Excel document is a CPU heavy task, i.e. your app will drain the battery much more than it should.
  4. Excel file stores much more information in addition to your raw data that is absolutely not needed for the data consumer such as a mobile app.
  5. It's very easy to accidentally break the data contract with the Excel file. Imagine that the app expects some value in the cell A1. If I insert a new column in the very beginning and make it hidden, the file will still look the same at first glance, but the consumer will not read it correctly.

If your data is fundamentally a hierarchy (a tree) of various objects with different sets attributes, use JSON or XML.

If your data is rather a set of similar objects (a table), use CSV.

Whether you choose JSON, XML or CSV, parsing them will be a much easier task for a mobile app.

If you need a convenient GUI to manually update a file like that, consider using Visual Studio Code with plugins. Or, in case of CSV, you can actually use Excel (just save the final result back to .csv rather than to .xlsx).

  • Related