How to generate a .xls file programmatically through my iPhone?
4 Answers
If you just want to put tabulated data into an spreadsheet, simply generate a .CSV file that can be directly read into EXCEL.
If you want a fully featured spreadsheet, with multiple sheets, formulas, formats, inserted objects, pictures, charts etc, then, as far as I know, there is no solution for iPhone, as Microsoft does not provide the equivalent to its Excel ActiveX component.
If your requirements lie in between, you might try some alternatives. Take a look at Google Docs or at QuickOffice.
I don't recommend you to try to generate a full XLS from scratch, if far too much dificult.

- 28,486
- 9
- 71
- 95
I have alternative solution for you.
It's easy to create a CSV
(comma seperated value) file using code then this CSV file can be directly opened by MS Excel in xls format.

- 5,837
- 8
- 34
- 61

- 321
- 1
- 4
- 16
-
Although its not recommended, if you want to create fancy xls files with bar and charts. – user1374408 May 10 '12 at 06:41
-
i tried that also but problem i am facing is i am able to open that file through xcel on desktop only because it first asks for encoding type then open it, but same file i cannot open in my iphone it says unable to load document – Anshul May 10 '12 at 06:47
-
have you renamed the created file as *.xls ? – user1374408 May 10 '12 at 06:52
-
yes i created the array and added items to the file and give .xls extension to it.It's working fine on my desktop just the problem is it asked for encoding type and then open it , problem is with iphone simulator , canot load it on it. – Anshul May 10 '12 at 06:55
-
but why you want to open on simulator ? which app you are using to open .xls file ? – user1374408 May 10 '12 at 06:59
-
i am laoding it on my webview – Anshul May 10 '12 at 07:00
-
There could be a problem with simulator.OR I think you should try this code which gives alternative way to display xls file. http://stackoverflow.com/questions/6983502/iphone-opening-word-excel-and-pdf-files-without-using-uiwebview – user1374408 May 10 '12 at 07:08
I haven't searched for third-party libraries about this before but at least it is possible (but not easy) for you to generate XLS files yourself per the specification of XLS file format:

- 42,163
- 6
- 44
- 69
Create an HTML table if you need to view it on the phone; in general, xls is a poor choice for data interchange format.

- 62,238
- 13
- 100
- 144
-
-
Yes, excel can import the HTML table, while you can preview it in the phone using the browser or by embedding the browser component to your app. – Lie Ryan May 10 '12 at 07:19