在 C# .NET 中查看 docx 文件
我需要创建 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
可能值得一看 Aspose.Words< /a>.为您处理所有 docx 格式,并以多种图像格式呈现文档页面以供查看。
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.
您可以使用 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.如果您坚持使用 mht 文件选项,则可以在 .NET Web 浏览器控件中查看它们。
If you stick with the mht file option, they can be viewed in the .NET web browser control.