创建类似 MS Office 文档的文件格式以公开文档属性

发布于 2024-08-17 07:51:50 字数 1432 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橙味迷妹 2024-08-24 07:51:50

我很确定您的最佳答案是使用 OLE 复合文档。

Microsoft 可能已停止使用此格式,但那是因为他们已采用 XML 文件格式。除非您愿意从当前的文件格式转换为 XML,否则我认为您不会对新的标签标准感兴趣。

您可以让您的应用程序保存两个文件,一个仅用于标签的 XML 文件和一个二进制数据文件,但这对您的用户来说意味着痛苦。 OLE 复合文档格式的全部要点是允许将多个“文件”绑定到一个文件中。

另外,如果现代 Windows 没有内置对 OLE 复合文档的支持,我会感到非常惊讶。我很确定,早在十多年前的 Microsoft Word 6.0 中,文档就以这种 OLE 复合文档格式保存。为什么 Windows XP 或更高版本需要额外的 .DLL 文件才能解析标签?

使用 OLE 复合文档格式的最好的一点是,用户标签将与文件一起使用,无论什么情况:如果用户将文件写入文件服务器,如果用户在电子邮件中删除文件,如果用户刻录将文件刻录到 CD 上,无论如何。 (我写的第一个答案很糟糕,我删除了它;即使它有效,它也会将用户标签放在文件之外,而且我越想它,我就越不高兴。)

所以,我建议您尝试创建一个 OLE 复合文档,然后在 Windows XP 标准安装中的 Windows 资源管理器中查看该文件。看看您是否可以在无需下载和安装 ActiveX .DLL 的情况下看到标签。我很确定它会起作用。 (但我不再真正做 Windows 了,所以我不能方便地为你测试这个。)

编辑:好的,我刚刚做了一个测试。我正在工作,这里有一台 Windows 计算机。我使用Word 2007制作了一个文档,并将文档保存为Word 97格式。我查看了 Windows 资源管理器中的文档属性;作者姓名在标签中可见。我在“注释”中添加了文本,然后在 Word 2007 中打开该文件。然后我就可以查看注释了(单击左上角的“Office”图标圆圈,选择“准备”,选择“属性”)。

所以,我的理论有一些证据支持它:我不需要安装任何特殊软件,我的 Windows 资源管理器只需使用带有标签的 OLE 复合文档格式 Word 文件即可。 (可能是 Microsoft Office 安装了一些特殊的 .DLL 以便在 Windows 资源管理器中使用标签;我确实在那台计算机上安装了 Microsoft Office 2007。但您的客户可能也有 Microsoft Office,所以即使是这种情况,我仍然我认为这是最好的解决方案。)

我建议你谷歌搜索“OLE复合文档格式”,看看如何编写这种格式。我在这里找到了如何阅读标签的示例: http://support.microsoft.com/kb/ 186898

I'm pretty sure your best answer is to use the OLE compound document.

Microsoft may have stopped using this, but that is because they have gone to an XML file format. Unless you are willing to convert from your current file format to XML, I do not think that the new standard for tags will be interesting for you.

You could possibly make your application save two files, the XML one just for tags and the binary data one, but that just means pain for your users. The whole point of the OLE compound document format was to allow multiple "files" bound together in one file.

Also, I would be very surprised if modern Windows did not have support for OLE compound documents built right in. I'm pretty sure that as far back as Microsoft Word 6.0, over a decade ago, documents were saved in this OLE compound document format. Why would Windows XP or newer require an extra .DLL file to be able to parse the tags out?

The best thing about using the OLE compound document format is that the user tags will go with the file, no matter what: if the user writes the file to a file server, if the user drops the file in an email, if the user burns the file to a CD, whatever. (The first answer I wrote, which I deleted, was bad; even if it had worked it would have put the user tags outside the file, and the more I think about it, the less happy I am at that thought.)

So, I suggest that you try creating an OLE compound document, and then just look at the file in Windows Explorer in a standard install of Windows XP. See if you can see the tags without needing to download and install an ActiveX .DLL. I'm pretty sure it will work. (But I don't really do Windows much anymore so I cannot conveniently test this for you.)

EDIT: Okay, I just did a test. I'm at work and I have a Windows computer here. I used Word 2007 to make a document, and I saved the document as Word 97 format. I looked at the document properties in Windows Explorer; the author name was visible in the tags. I added text to "comments" and then opened the file in Word 2007. I was then able to view the comments (click on the "office" icon circle in the upper left, choose "Prepare", choose "Properties").

So, my theory has some evidence to support it: I did not have to install any special software, my Windows Explorer just worked with the OLE compound document format Word file with the tags. (It could be that Microsoft Office installs some special .DLL to use the tags with Windows Explorer; I do have Microsoft Office 2007 installed on that computer. But your customers likely have Microsoft Office too, so even if that is the case, I still think this is the best solution.)

I suggest you Google search for "OLE compound document format" and see how to write this format. I found an example of how to read the tags here: http://support.microsoft.com/kb/186898

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文