目前我正在开发一个用c#和& amp; asp 用户可以存储批量文件。现在我想查看在浏览器中打开的所有可查看格式的文件(即图像,ms office,pdf等)(无需在客户端本地计算机中下载)。我已经完成了一半的工作,即我的应用程序适用于所有图像文件和pdf文件。但我面临ms office文件(即xls,xlsx,doc,docx,ppt等)格式的问题。我尝试了一些代码
Currently I am working on a file management system which developed in c# & asp Where user can store bulk files. Now I want to view all viewable formats of file (i.e. image, ms office, pdf etc) open in browser (without downloading in clients local machine). I already done half of my job i.e. my application working fine for all image files and pdf files. But I facing problem with ms office files (i.e. xls, xlsx, doc, docx, ppt etc) formats. I tried some piece of code
protected void Page_Load(object sender, EventArgs e) { //Set the appropriate ContentType. string FilePath = MapPath("Test/xyz.pdf"); Response.Buffer = true; Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "Application/pdf"; Response.AddHeader("content-disposition", "inline; filename=\"" + "xyz.pdf" + "\""); Response.Write(FilePath); Response.End(); }此代码仅适用于.pdf文件,但当我更改内容类型为Response.ContentType for word或excel文件Application / msword(对于Microsoft Word文件)Application / x-msexcel(对于Microsoft Excel文件)然后此代码不起作用。请指导我该怎么办。我应该使用任何工具,如谷歌文档查看器或其他东西。如果只有工具,那么请建议我一个很好的工具。 提前谢谢
This code works fine only for .pdf files but when I changed my content type Response.ContentType for word or excel files Application/msword (for Microsoft Word files) Application/x-msexcel (for Microsoft Excel files) then this code not works. Please guide me what can I do. Should I use any tool like google documents viewer or some thing else.If it is possible only with tool then please suggest me a good tool for this. Thanks in advance
推荐答案简而言之:Office格式现已公开发布并标准化(请参阅下面的链接),但Web标准不支持它们,因此您需要代表他们的内容并显示为HTML。 请参阅我过去的答案,了解如何处理这些文件。您应该将自己的映射设计为HTML并实现HTML内容的生成。请参阅: 将Office文档转换为PDF而无需互操作 [ ^ ], 需要一个相当独特的WPF文本编辑器控件 [ ^ ], 您好如何使用c# 在Windows应用程序中显示word文件[ ^ ], 不使用Interop读取word文件.word dll ...不想在IIS中安装单词。 [ ^ ]。
更多推荐
如何在asp.net 4.0,C#Web应用程序中在线查看MS office文件
发布评论