.docx和.doc文件的结构是什么? [英] What is the structure of a .docx and .doc file?

查看:384
本文介绍了.docx和.doc文件的结构是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解到.docx文件基本上是二进制文件.但是我不知道下面的结构.

.docx文件的基本结构是什么?例如,标题多长时间?实际文档内容从哪一点开始?末尾有签名吗?

基本上,.docx文件的结构是什么?

解决方案

我要回答这个问题: " DocX文件的结构是什么?"

官方答复

请参阅OOXML的官方文章"OOXML的剖析".DocX目录结构示例:

http://officeopenxml.com/anatomyofOOXML.php

以DocX XML文档为例:

http://officeopenxml.com/WPsampleDoc.php

我个人建议

但是 ,一丝不苟地遵循这些步骤,并猜测细节在哪里变得模糊,我无法制作 .docx 文件./p>

我选择了此快捷方式:在Libre Office中创建一个 Docx 文件(支持 .docx 扩展名),并在您希望生成的docx文件的格式,将文件另存为.docx,复制并另存为.zip.

打开此.zip目录,您会发现与上面的官方链接相比,我在解释规范方面要好得多.

示例

例如,如果您要使用.docx撰写文章,则标题框/格式中的顶部应具有 [[Title]] ]] (例如作者等),然后使用您的代码,使用该模板,然后将 [[field]] 换成任何 $ data 您已经准备好放入其中了.

I have learned that .docx files are basically binary files. But I'm unaware of the structure that lies beneath.

What is the essential structure of a .docx file? Like, how long is the header? From what point does the actual document content start? Does it have any signature at the end?

Basically, what's the anatomy of a .docx file?

解决方案

I am going to answer this question: "What's the Anatomy of a DocX File?"

Official Answer

Please see the official OOXML article, "Anatomy of OOXML," for an example DocX directory structure :

http://officeopenxml.com/anatomyofOOXML.php

For an example DocX XML document :

http://officeopenxml.com/WPsampleDoc.php

What I Personally Suggest

HOWEVER, after following these meticulously, and guessing where the details got foggy, I was unable to make the .docx file.

I chose this short cut : Make a Docx file in Libre Office (supports .docx extensions), make a generic template in the format of the docx files you expect to be generating, save the file as .docx, copy and save as .zip.

Open this .zip directory, and what you'll see I found to be much better at explaining the spec than the above, official links.

Example

For example, if you're making articles in .docx, you'd have [[Title]] at the top in title-casing/formatting, By: [[Author]], for author, etc., etc.. Then with your code, use that template, and just swap out the [[field]] for whatever $data you're ready to put into it.

这篇关于.docx和.doc文件的结构是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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