从Asp.net.C#打开Word文档 [英] Opening Word Document from Asp.net.C#

查看:79
本文介绍了从Asp.net.C#打开Word文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Asp.net打开Word文档

我使用了以下代码

I am trying to open a word document from Asp.net

i used the following code

object fileName = strFileName;
            object readOnly = false;
            object isVisible = true;
            object missing = System.Reflection.Missing.Value;
            oWordApplic.Visible = true;
            oDoc = oWordApplic.Documents.Open(ref fileName, ref missing, ref readOnly,
                ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
                ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing);
            oDoc.Activate();



我现在的问题是一切都挂起了.我可以看到WORD.exe在ASPNET用户(通过任务管理器)中处于活动状态,但是绝对没有任何反应. Web进程可能会经历25%的过程,然后才挂起.


并且,如果我们通过任务管理器停止WORD.exe,则它将显示远程过程调用失败错误消息"

请帮助我,



My issue now is that everything just hangs. I can see that WORD.exe is active with the ASPNET user(By task manager), but absolutely nothing happens; the web process maybe goes 25% of the way through and then just hangs.


And if we stops the WORD.exe via task manager,then it will show "Remote Procedure Call Failed error message"

Please help me,

推荐答案

检查此链接

查看此链接:

来自ASP.NET的Microsoft Word文档

我希望它能对您有所帮助:)
See this link :

Microsoft Word Documents from ASP.NET

I hope it will help you :)


不确定您为什么有这样的代码来打开word文档,我相信您正在构建供用户远程使用的asp.net Web应用程序.

如果我的假设是正确的,那么即使您的代码也可以在本地计算机上运行,​​最终用户将其部署到生产服务器上时,它将对用户不起作用,因为它将在服务器上打开word文档,对用户没有任何回报.

在针对请求的客户端-服务器应用中,Web应用程序必须发送一些数据作为具有有效MIME类型的响应,以便客户端浏览器可以采取适当的措施.话虽如此,我相信您应该更新代码,以便用户可以下载文件,即在单击soem按钮或链接时打开一些文件.

参见以下链接:
Not sure why you have code like this to open a word document i believe you are building a asp.net web application that the users can use remotly.

If my assumption is true even your code works on your local machine it wont work for the users when finally you will deploy it on production server as it will open the word document on server and return nothing to user.

in a client-server appilcation for a request web application must send some data as response with valid MIME type so that client browser can take appropriate action. having that said i believe you should update your code so that user can download the file i.e. open some file on clicking of soem button or link.

see below link:
http://stackoverflow.com/questions/2519026/how-do-you-stream-an-excel-2007-or-word-2007-file-using-asp-net-and-c-sharp[^]

If you are trying to edit a word doc file in your asp.net file then that is a different story.


这篇关于从Asp.net.C#打开Word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆