简体   繁体   English

在iOS上将数据导出到XLS(不是通过CSV)

[英]Export data to XLS (not via CSV) on iOS

I need to export some data to an .XLS file, pdf, and print. 我需要将一些数据导出到.XLS文件,pdf和print。

I already tried the simple solution: exporting it to .CSV with CHCSVWriter . 我已经尝试过简单的解决方案:使用CHCSVWriter将其导出到.CSV。 It works for printing and saving it to pdf (I open the CSV in a UIWebView and get the PDF or print from there). 它适用于打印并将其保存为pdf(我在UIWebView中打开CSV并从那里获取PDF或打印)。 However, to use the CSV to be open in excel has two main problems: 但是,要在Excel中使用CSV打开有两个主要问题:

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 . 1 - 首先,正如名称所示,在CSV中,值以逗号分隔, 在某些版本的Excel中,它要求用户在单元格中“手动”分隔

2 - I have hebrew characters, and I already tried all the string encodings, and can't have both hebrew and latin characters. 2 - 我有希伯来字符,我已经尝试过所有字符串编码,并且不能同时拥有希伯来字符和拉丁字符。

So, after giving up after days of trying to use CSV to solve the issues above, I gave up. 因此,在尝试使用CSV解决上述问题几天之后放弃后,我放弃了。 How can I export my data to XLS? 如何将数据导出到XLS?

The LibXL library provides this functionality for both xls and xlsx formats. LibXL库为xlsxlsx格式提供此功能。 There is no iOS version, but people say the iOS version is coming. 没有iOS版本,但人们说 iOS版本即将推出。 You may want to contact LibXL support to confirm this. 您可能需要联系LibXL支​​持以确认这一点。

EDIT: The iOS version is available now. 编辑:iOS版现已上市。

This article explains how to programmatically create an Excel ( .xls ) file without using any external library. 本文介绍如何以编程方式创建Excel( .xls )文件而不使用任何外部库。 It just opens a file stream and it writes XML contents straight to it. 它只是打开一个文件流,它直接将XML内容写入其中。

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. 它是用C#编写的,但其中的核心信息是用于创建节点和填充相应单元格值和格式的属性的XML格式。

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. 请随意询问一些C#位是否不清楚。 HTH HTH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM