Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i create excel sheet and file in iPhone sdk?

i want to generate the application to create the excel file in iPhone sdk. can anybody suggest me to create it.

like image 974
Jaspreet Singh Avatar asked Aug 02 '12 10:08

Jaspreet Singh


3 Answers

Well, the right guy saw your post! There is an open source C++ library on SourceForge, xlslib, that will do exactly what you need.

But wait - there's even more! There is a Objective-C wrapper to that library - its a bit out of date but recently someone reported that they got it to work on iOS.

The two people supporting this library appear to be quite responsive to users, so its likely that they will continue to support the ObjectiveC wrapper if people are using it.

That said, there is no out-of-the-box library/framework to just stick in your project. You will have to spend some time, maybe even a day or two, to get the thing to build and run on iOS. If you are in a hurry you will have to spend the time. If you are patient you may get help on it.

EDIT: there is an ObjectiveC framework using this library: JXLS.

like image 126
David H Avatar answered Nov 16 '22 02:11

David H


Another option if your Excel file isn't very complicated would be to use an HTML table. I've tried it and it works pretty well.

NSURL * docsDir = [NSFileManager.defaultManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask].lastObject;
NSURL *file = [docsDir URLByAppendingPathComponent:@"sample.xls"];
NSString* htmlString = @"<table>
  <tr>
    <th bgcolor="#00FF00">Month</th>
    <th  bgcolor="red">Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table>";

[htmlString writeToFile:file.path atomically:YES encoding:NSUTF8StringEncoding error:nil];

Once created the file, attach it to an e-mail with XLS extension and open it with Excel.

To try if this solution fits your needs you could create plain text file with your "HTML template" and open it with Excel. Once checked create it programmatically :)

like image 28
Jordi Corominas Avatar answered Nov 16 '22 00:11

Jordi Corominas


I found a link on github. Just add these few files & follow instruction for integrating code(easy to integrate).

Here is Link
https://github.com/andreac/RSSheet

Please convert these files into ARC to avoid crashing due to memory management. Hope it works.

like image 23
Gagan_iOS Avatar answered Nov 16 '22 02:11

Gagan_iOS