读取或转换Word .doc文件iOS [英] Reading or Converting word .doc files iOS

查看:85
本文介绍了读取或转换Word .doc文件iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS上的其他应用程序如何读取和编写Word文档?我看到与此有关的其他一些问题,并且公认的答案都遵循无法完成"的思路.我不想只显示一个单词doc,而是要阅读它的格式.其他应用程序如何执行这些操作,它们是否使用Microsoft发布的已发布标准自行编写解析?他们在处理文件之前是否使用某种捆绑的实用程序将文件转换为其他格式,例如XML或HTML?有开源的方法吗?寻找想法.

How are other apps on iOS able to read and write word docs? I see some other questions related to this and accepted answers are along the lines of "it can't be done." I don't want to just display a word doc, I want to read it along with its formatting. How are other apps doing it, are they writing the parsing themselves using the published standard put out by Microsoft? Are they using some kind of bundled utility to convert the file to some other format like XML or HTML before processing it? Is there an open source way of doing this? Looking for ideas.

推荐答案

我不知道您是否还在寻找解决方案,还是您自己想出了解决方案,但我正在回答,希望它可以帮助其他人寻找相同的解决方案.

I don't know if you are still looking for solution or you figured it yourself but I am answering this hoping it will help someone else looking for the same.

我一直在寻找与我的任务相关的解决方案,我希望将Word文件转换为文本文件.经过一番谷歌搜索后,我遇到了这个问题,根据@TJD的回答,我进入了链接然后从那里找到此链接.

I was looking for a solution related to my task that I want to convert word file to text file. I came on this question after some googling and according to the answer from @TJD I gone on the link and from there I found this link.

根据我的要求,因为我需要将Word文件转换为文本文件.我按照第二个链接作为解决方案.

For my requirement as I was needed to convert word file to text file. I followed second link as my solution.

由于docx文件是用 Open XML File format 创建的,并且在那里提到,我知道我需要将docx文件考虑为zip来解压缩.

As the docx file is created with Open XML File format and it is mentioned in there I understand that I need to unzip the docx file considering it a zip.

对于Zip/Unzip,Google提供了此处的代码.根据 Wikipedia链接将docx文件解压缩到我们的文档目录中之后,便有了三个目录和一个xml根目录中的文件.

For Zip/Unzip google provides code here. After unziping the docx file in our document directory according to the wikipedia link there are three directories and one xml file in root.

对于我的解决方案,我选择链接中提到的 word 目录,文件的原始内容放置在该目录中(到目前为止,我没有进入任何其他目录或文件).提取路径 word/doctment.xml 下有一个文件,这是您docx文件内容以xml格式放置的地方.

For my solution I choose word directory as mentioned in link that original content of file is placed there (I didn't gone in any other directory or file till now). There is a file under your extract path word/doctment.xml this is where your docx file content placed in xml format.

该xml文件中有很多可用的标签,我现在不知道这些文本的含义,但是查看xml文件后,我发现包含我的文本的标签为 w:t .

There are lots of tags available in that xml file and I don't know the meaning of those text right now but after looking at the xml file I got that the tag which contain my text is w:t.

在那之后,每件事都像蛋糕.我只是使用 NSXMLParser 并从以 w:t 标记为目标的xml文件中解析了数据,然后得到了我的整个字符串.

After that every thing is like cake. I just used NSXMLParser and parsed the data from the xml file targeting the w:t tag and I got my whole string.

注意:一旦了解其他文件和标签,我将立即更新答案.同样,由于我知道MSOffice 2007中引入了 OpenXMLFile格式,因此该解决方案不适用于doc文件,因此我还将更新doc文件解决方案的答案.

Note: I will update my answer as soon as I understand about the other files and tags. As well this solution is not working with doc files as of I know OpenXMLFile format is introduced in MSOffice 2007 so I will also update my answer for doc file solution.

我知道这还不够,它还不包括创建doc文件等.但是我希望这对我们很多人有帮助.

I know this is not enough that it is not covering creating doc file etc. But I hope this will help lots of us.

这篇关于读取或转换Word .doc文件iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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