Export data to XLS (not via CSV) on iOS

夙愿已清 提交于 2019-12-10 22:09:10

问题


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?


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/15269767/how-to-create-a-custom-xls-file-programmatically-in-ios

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!