如何从iPhone sdk中收集的数据以编程方式生成word文件 [英] How to generate a word file programmatically from collected data in iPhone sdk

查看:126
本文介绍了如何从iPhone sdk中收集的数据以编程方式生成word文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个iPhone应用程序,其中包含一些表格,我从中收集用户的数据。现在在这些表单的末尾,在用户填写了所有数据之后,我希望导出所有收集的数据并生成MS word .doc文件。数据也不是简单的文本。有标题,表格和普通文本。我有什么方法可以做到这一点吗?

I have an iPhone app consisting of a few forms in which I collect data from users. Now at the end of these forms, after user has filled all data, I want that all the collected data is exported and a MS word .doc file is generated. The data too is not simple text. There are headings, tables along with normal text in it. Is there any way I can accomplish this?

推荐答案

简短回答是的,答案很长:

Short answer yes, long answer:

你不能这样做来创建正确的Word文档,但是你应该能够在任何平台上通过从HTML构建doc这个单词并使用.doc扩展名保存它来代替HTML(而不是HTML)。 )。你可以把任何东西放在那里,自定义布局 - 我可能会坚持使用段落和表格以及浮动元素(比如imgs等)。

You can't do this to create "proper" Word documents, however you should be able to acomplish this on any platform by building the word doc from HTML and saving it with a .doc extension (instead of HTML). You can put anything in there, custom layouts - I'd probably stick to paragraphs and tables and floated elements (like imgs and such).

可能有额外的代码你将需要在HTML文档中(例如,使其在页面视图中而不是在HTML视图中打开),但您可以通过以HTML格式保存单词doc来解决所有问题。 :)如果你知道在哪里看,网上还有很多关于它的信息。

There may be extra code you will need in the HTML doc (for instance to make it open in page view rather than in HTML view) but you can figure all that out by saving a word doc in HTML format. :) There's also a lot of information on the internet about it if you know where to look.

我不久前做了类似的事情。我会看看能否找到一个例子并在此处发布。

I did something like this not long ago. I'll see if I can find an example and post it here.

这是唯一的我在html word doc中的自定义内容:

This is the only "custom" stuff I have in my html word doc:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:v="urn:schemas-microsoft-com:vml" 
    xmlns:o="urn:schemas-microsoft-com:office:office" 
    xmlns:w="urn:schemas-microsoft-com:office:word" 
    xmlns="http://www.w3.org/TR/REC-html40">

这是 - 在页面视图中打开它:

And this - to make it open in Page view:

<!--[if gte mso 9]><xml> 
     <w:WordDocument> 
      <w:View>Print</w:View> 
      <w:Zoom>100</w:Zoom> 
     </w:WordDocument> 
    </xml><![endif]--> 

其余部分只是标准的HTML和CSS(记得将CSS INSIDE放在HTML文档中< style> 标签 - word不会远程获取你的css文件。)

The rest of it is just standard HTML and CSS (remember to put CSS INSIDE the HTML document in <style> tags - word isn't going to remotely fetch your css files).

这篇关于如何从iPhone sdk中收集的数据以编程方式生成word文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆