如何在 SQL Server 中存储 Microsoft Word 文档的格式化片段
我需要提取 Word 文档的格式化文本片段并将其存储在 SQL Server 表中,以便稍后处理,然后使用 C# 重新插入到 Word 文档中。
我查看了 Word DOM,似乎我需要使用 Document.Load()、Document.Save() 和 Range.Copy()、Range.Paste() 方法的组合来创建文件对于我随后加载到数据库中的每个片段。
难道没有更简单(更有效的方法)吗?
顺便说一句,代码片段可以是隐藏文本,我正在考虑将代码片段存储为 RTF。
I need to extract formatted text snippets of a Word document and store it inside an SQL Server table, for later processing and then reinsertion in the Word document using C#.
I've had a look at the Word DOM and it seems that I need to use a combination of the Document.Load(), Document.Save() and Range.Copy(), Range.Paste() methods to create a file for each snippets that I then load into the DB.
Isn't there a easier (more efficient way)?
By the way the code snippets can be hidden text and I was thinking about storing the snippets as RTF.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最后我必须使用 Aspose.Words for .NET 从我感兴趣的 Word 文件中提取代码片段并将其存储为 RTF:
然后可以将 rtf 存储到数据库的文本字段中,如下所示通常并在 RTF 文本控件中编辑它。
Finally I got to use Aspose.Words for .NET to extract the code snippets from the Word file I'm interested in and store them as RTF:
One can then store the rtf into a text field of the database as usual and edit it in a RTF text control.
Document.load,然后通过 RANGE 对象选择范围,然后使用范围对象的 XML 属性获取该范围的 XML 并存储它。
您可以稍后使用相反的过程将 XML 插入到另一个文档中。
不过,编辑这些片段可能会很有趣,因为我不知道有任何基于 Web 的 WORD 兼容编辑器。
Document.load, then select the range via a RANGE object, then use the XML property of the range object to get the XML of that range and store it.
You can later insert the XML into another document using the reverse process.
Editing the snippets might prove interesting though, because I'm not aware of any web based WORD compatible editors.