在 C# .NET 中查看 docx 文件

发布于 2024-09-25 15:59:12 字数 350 浏览 2 评论 0原文

我需要创建 C# .NET 解决方案来直接从数据库查看 .docx 文件,而无需在硬盘上写入。最可行的方法是什么?

一种选择是将 docx 文件转换为 .mht 格式并以 blob 类型保存在数据库中。但我找不到直接从数据库查看的方法。

另一种方法是将docx文件转换为.jpg文件,可以使用.NET中的picturebox控件直接从数据库中查看该文件。采取的方法是首先将 docx 转换为 .mdi,然后转换为 .tiff 格式(使用 Microsoft Image Writer),最后转换为 jpeg。但这涉及多个IO操作,降低了解决方案的效率和可靠性。

如果有人知道改进上述选项的方法或任何新想法,我们将不胜感激。 提前致谢 :)

I need to create C# .NET solution to view a .docx file directly from the database without writing on the hard disk. What would be the most feasible approach ?

One option would be to convert the docx file to .mht format and save in the database as blob type. But I could not find a way to directly view it from the database.

Another way is to convert the docx file to .jpg file which can be directly viewed from the database using picturebox control in .NET. The approach taken was to first convert docx to .mdi and then to .tiff format (using Microsoft Image Writer) and the converting to jpeg. But this involves several IO operations which reduces the efficiency and reliability of the solution.

If anyone know ways of improving the above options or any new ideas it would be really appreciated.
thanks in advance :)

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

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

发布评论

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

评论(3

回忆那么伤 2024-10-02 15:59:12

Might be worth looking at Aspose.Words. Handles all the docx format for you and they render a page of the document in several image formats for viewing.

吲‖鸣 2024-10-02 15:59:12

您可以使用 OpenXML Writer (开源)之类的方法,但不是在磁盘上打开文件,使用 MemoryStream 处理数据库中的数据。

You could use an approach like OpenXML Writer (open source) does but instead of opening a file on disk, use a MemoryStream with the data from the database.

作死小能手 2024-10-02 15:59:12

如果您坚持使用 mht 文件选项,则可以在 .NET Web 浏览器控件中查看它们。

If you stick with the mht file option, they can be viewed in the .NET web browser control.

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