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 ?
我需要创建c# . net解决方案来直接从数据库中查看.docx文件,而不需要在硬盘上写入。最可行的方法是什么?
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.
一种选择是将docx文件转换为.mht格式,并以blob类型保存在数据库中。但是我找不到从数据库直接查看它的方法。
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.
另一种方法是将docx文件转换为.jpg文件,可以使用. net中的picturebox控件从数据库中直接查看该文件。所采取的方法是首先将docx转换为.mdi,然后转换为.tiff格式(使用Microsoft Image Writer),然后转换为jpeg。但这涉及到几个IO操作,降低了解决方案的效率和可靠性。
If anyone know ways of improving the above options or any new ideas it would be really appreciated. thanks in advance :)
如果有人知道如何改进上述选项或任何新想法,我们将非常感激。提前谢谢:)
3 个解决方案
#1
2
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.
也许值得一看。为您处理所有的docx格式,它们以几种图像格式呈现文档的页面供查看。
#2
0
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.
您可以使用像OpenXML Writer(开源)那样的方法,但是不需要打开磁盘上的文件,而是使用内存流来处理来自数据库的数据。
#3
-1
If you stick with the mht file option, they can be viewed in the .NET web browser control.
如果您坚持使用mht文件选项,可以在. net web浏览器控件中查看它们。
#1
2
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.
也许值得一看。为您处理所有的docx格式,它们以几种图像格式呈现文档的页面供查看。
#2
0
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.
您可以使用像OpenXML Writer(开源)那样的方法,但是不需要打开磁盘上的文件,而是使用内存流来处理来自数据库的数据。
#3
-1
If you stick with the mht file option, they can be viewed in the .NET web browser control.
如果您坚持使用mht文件选项,可以在. net web浏览器控件中查看它们。