Q: is it possible to create .xls file through iOS programmatically? How to generate a .xls file programmatically through my iPhone?

A: 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.

A: 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.

A: 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:


*

*Microsoft Office Excel 97 - 2007 Binary File Format Specification (*.xls 97-2007 format)

*OpenOffice.org's Documentation of the Microsoft Excel File Format

A: Create an HTML table if you need to view it on the phone; in general, xls is a poor choice for data interchange format.
