在 .NET 中编程 Word XML
我目前在一个开发团队中,试图开发一个应用程序,该应用程序能够接受 Open XML Word 文档、分解 XML 并以某种方式动态显示可用于数据输入的 UI 屏幕。
我正在使用 Open XML SDK,但我面临的挑战是提出一种非常通用的方法来表示文档,因为 SDK 要求在代码中定义静态表示(称为模板或掩码),然后可以使用以编程方式粉碎文档。
作为粉碎某个文档的示例,我必须进入代码并定义单词文档的主题、字体、段落样式等,以便程序“知道”如何粉碎它。如果文档的样式发生变化那么程序也必须改变。
我的问题是,有没有一种方法可以通用地执行此操作,以便我不必关心在生成单词文档时使用的样式?以前是否有人尝试过从 Word 文档生成屏幕/数据输入字段。
任何帮助将不胜感激。
I'm currently in a development team trying to come up with an app that will be able to accept an Open XML Word document, shred the XML and somehow come up with UI screens on the fly that could be used for data entry.
I'm using the Open XML SDK but my challenge has been to come up with a very generic means of representing the document as the SDK requires that a static representation (call it a template or mask) be defined in code which can then be used to shred the document programmatically.
As an example to shred a certain doc, i have to go into code and define the theme, fonts, paragraph style etc of the word doc in order for the program to "know" how to shred it.If the style of the doc changes then the program also has to change.
My question is, is there a way of doing this generically so that i wont have to care about the style used in coming up with the word document? Has anyone attempted generating screens/ data entry fields from a word document before.
Any help will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Open XML 允许您使用 xml 架构通过 内容控制。然后,您可以使用 xml 架构作为数据输入应用程序的起点。
将内容控件映射到自定义 xml:
您可以控制文档中的自定义 xml 并且您的 UI 非常静态,或者您可以基于自定义 xml 模式即时生成数据输入用户界面
我认为有一种方法可以让 Word 本身充当您的数据输入 UI,因此您甚至不需要自定义 UI。
Open XML allows you to use an xml schema to bind data to certain parts of the document with content controls. You can then use the xml schema as a starting point for your data entry app.
Mapping content controls to custom xml:
Either you have control over the custom xml in the document and your UI is pretty static, or you could generate a data entry user interface on-the-fly based on the custom xml schema
I think there is a way to have Word itself serve as your data-entry UI, so you won't even need a custom UI.