使用asp.net和c#在browswe中显示word doc

时间:2013-03-01 17:37:05

标签: c# asp.net

好吧所以基本上我想在浏览器中显示一个word doc,因为没有编辑需要从文件和显示访问....我不是特别关于它是一个单词doc但我希望显示继承文本格式,也许如果可能的话甚至包括照片。我目前使用了以下一组代码

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网络应用程序上使用它时它会给我以下错误

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 标记

0 个答案:

没有答案