2

I want to have an iPhone app where the user can export the data held by the application to an Excel spreadsheet (as well as a host of other formats).

So the idea is that each entity would be a new row in the sheet, with the attributes being different columns.

Is this possible?

Zac Altman
  • 1,215
  • 4
  • 25
  • 37
  • It would be easier to format it into a format that Excel/others can import (e.g. CSV or XML). How are you delivering the file? Email? – gerry3 Jan 14 '10 at 22:45
  • Email, as well as web upload. I just want to end user to be able to get the data in Excel, so if it is by importing another format, then that is fine. – Zac Altman Jan 14 '10 at 22:49

1 Answers1

1

Excel and similar programs can import files that are in a delimited text format such as CSV.

It is definitely possible to manipulate Core Data attributes into strings and then combine them in such a format using the strategy that you describe: instances of an entity are rows and attributes are columns.

Note: you would need a different file for each entity that you wanted to export.

Do you need to do anything with the relationships between entities?

Did you have a specific concern?

gerry3
  • 21,420
  • 9
  • 66
  • 74
  • there are no relationships between entities. The data is almost like a contact list where in each entity you have the persons name, email, phone, etc. The separate files would be useful in one respect, but ideally it would be one larger file - unless excel can import multiple CSV files into one sheet (not sure if it can do that) in which case it would be fine. – Zac Altman Jan 14 '10 at 23:16
  • How many different entities do you have? Do they all inherit from the same parent class? If not, how can you put them all in same spreadsheet? They would have different columns (due to different attributes). – gerry3 Jan 15 '10 at 05:37
  • Only one type. Its very similar to a contact. The attributes are the same (e.g Name, Phone, Email) – Zac Altman Jan 22 '10 at 11:14
  • In that case, I agree that you would only need one spreadsheet. – gerry3 Jan 22 '10 at 12:00
  • so now the question is, how do i export it to a CSV file? – Zac Altman Jan 22 '10 at 12:19
  • You are going to have to be more specific. Do you need help converting your Core Data attributes into strings? Do you need help converting the strings into data (NSData)? – gerry3 Jan 22 '10 at 12:26
  • @gerry3:I have image as NSData in the database, how should i send them in a csv file?see me question http://stackoverflow.com/questions/5194501/convert-nsdata-of-image-from-database-to-nsstring-in-iphone.Please help.. – Warrior Mar 04 '11 at 14:50
  • @Warrior What happens when you export an Excel spreadsheet with an image in a cell to CSV? I imagine the image is lost. I also imagine that exporting to Excel from iOS will be very difficult. I would recommend an alternative solution if possible. – gerry3 Mar 05 '11 at 01:05