Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用asp.net和c在浏览器中显示word文档#_C#_Asp.net - Fatal编程技术网

C# 使用asp.net和c在浏览器中显示word文档#

C# 使用asp.net和c在浏览器中显示word文档#,c#,asp.net,C#,Asp.net,好的,所以基本上我想在浏览器中显示一个word文档,因为从文件和显示中,几乎不需要编辑。。。。我对它是word文档并不特别在意,但我希望它的显示能够继承文本格式,如果可能的话,甚至可以包括图片。我目前使用了以下代码集 protected void Page_Load(object sender, EventArgs e) { if (Session["Link"] != null) { String

好的,所以基本上我想在浏览器中显示一个word文档,因为从文件和显示中,几乎不需要编辑。。。。我对它是word文档并不特别在意,但我希望它的显示能够继承文本格式,如果可能的话,甚至可以包括图片。我目前使用了以下代码集

protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Link"] != null)
            {
                String link = Session["Link"].ToString();
                ApplicationClass appClass = new ApplicationClass();
                object missing = System.Reflection.Missing.Value;
                object visible = true;
                object readOnly = true;
                object fileName = link;
                Document wordDoc = appClass.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref visible, ref missing, ref missing, ref missing, ref missing, ref missing);
            TextArea1.InnerText = wordDoc.Content.Text;

            appClass.Application.Quit(ref missing, ref missing, ref missing);

        }
        else
        {
            DataSet ds = new DataSet();
            ds = WCGSQL.showdata("select max(Date) from WeeklyMsg");
            if (ds != null)
            {
                String MaxDate = ds.Tables[0].Rows[0][0].ToString();
                ds = WCGSQL.showdata("select * from WeeklyMsg where Date='" + MaxDate + "'");
                String link = ds.Tables[0].Rows[0][0].ToString();
                String Path = "i:\\Website/WebSite3/WMSG/" + link;
                ApplicationClass appClass = new ApplicationClass();
                object missing = System.Reflection.Missing.Value;
                object visible = true;
                object readOnly = true;
                object fileName = Path;
                Document wordDoc = appClass.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref visible, ref missing, ref missing, ref missing, ref missing, ref missing);

                TextArea1.InnerText = wordDoc.Content.Text;

                appClass.Application.Quit(ref missing, ref missing, ref missing);
            }
        }
    }
该文件适用于asp网站,但当我在asp web应用程序上使用该文件时,会出现以下错误

Error   2   Task could not find "AxImp.exe" using the SdkToolsPath "C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\" or the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A". Make sure the SdkToolsPath is set and the tool exists in the correct processor specific location under the SdkToolsPath and that the Microsoft Windows SDK is installed   WebApplication2
非常愿意接受任何可以解决这个问题的想法,即使是外部应用程序(最好是为非营利组织免费创建网站,所以预算非常有限)

提前thx
标记调试此行时
Path
的值是多少
String Path=“i:\\Website/WebSite3/WMSG/”+链接?哦,对不起,忘了提到我的文件名保存在数据表中的一个表中,因此基本上,
+链接
部分将是文件名,因为它是可变的,其余部分是常量,我使用的是引用Microsoft.Office.Interop.Word;对于上面的代码,请看这个:thx的信息,但我确实看到了上面的论坛链接之前,我的问题是im使用iis生成的url,因此与谷歌文件看起来像这样,但当我运行它显示一个错误,从谷歌文件和点击这里,导致我下载的文件,我不想我只需要显示它在那里我做错了什么?