4

I need to export some data to an .XLS file, pdf, and print.

I already tried the simple solution: exporting it to .CSV with CHCSVWriter. It works for printing and saving it to pdf (I open the CSV in a UIWebView and get the PDF or print from there). However, to use the CSV to be open in excel has two main problems:

1 - First, as the name says, in the CSV the values are separated by commas, and in some versions of Excel, it requires the user to separate 'manually' in cells.

2 - I have hebrew characters, and I already tried all the string encodings, and can't have both hebrew and latin characters.

So, after giving up after days of trying to use CSV to solve the issues above, I gave up. How can I export my data to XLS?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Natan R.
  • 5,141
  • 1
  • 31
  • 48

2 Answers2

3

The LibXL library provides this functionality for both xls and xlsx formats. There is no iOS version, but people say the iOS version is coming. You may want to contact LibXL support to confirm this.

EDIT: The iOS version is available now.

Community
  • 1
  • 1
Adam
  • 26,549
  • 8
  • 62
  • 79
  • Thanks, Adam. Any other possible approach? – Natan R. Jul 18 '12 at 12:33
  • @NatanR. I would recommend using `xlsx` format, if possible. It can be open with older Excel versions with add-on installed. It's an open, xml based format and the files are smaller compared to `xls`. – Adam Jul 19 '12 at 11:31
  • Thanks for the comments, @Adam. But I still need to know how to do it =( – Natan R. Jul 19 '12 at 11:34
  • I have succesfully created the .xls (xml based), and it can be opened normally in excel. But it doesn't open in a UIWebView or in Numbers. Do you have any idea why? Trying to save as .xlsx doesn't solves the problem... – Natan R. Jul 30 '12 at 07:48
2

This article explains how to programmatically create an Excel (.xls) file without using any external library. It just opens a file stream and it writes XML contents straight to it.

It is written in C#, but the core information coming out of it is the XML formatting used to create nodes and fill attributes for corresponding cell values and formatting.

Please consider I have not tried this myself, I found it while doing a search. Please feel free to ask if some C# bits are not clear. HTH

superjos
  • 12,189
  • 6
  • 89
  • 134
  • 1
    I worked on this today and I'm starting to have something good. I'll try to build some sort of XLS writer and I'll post here the answer. Thanks a lot. – Natan R. Jul 25 '12 at 21:10
  • The only problem is that preview in iOS (UIWebView) and Numbers are not able to open this file =( So I am still searching another solution, but it was, no doubt, a good idea. – Natan R. Aug 21 '12 at 10:17
  • Having a look at [this thread](https://discussions.apple.com/thread/2039521?start=0&tstart=0) and at [this article](http://www.ehow.com/info_12129583_can-iwork-open-xlsx-files.html) it should possible with Numbers 2009. Never ever tried though – superjos Aug 21 '12 at 13:53