views:

493

answers:

1

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?

+1  A: 

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
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
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
Only one type. Its very similar to a contact. The attributes are the same (e.g Name, Phone, Email)
Zac Altman
In that case, I agree that you would only need one spreadsheet.
gerry3
so now the question is, how do i export it to a CSV file?
Zac Altman
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