尝试在视图中查看Word文档(ASP.NET MVC) [英] Trying to view word doc in a view (ASP.NET MVC)

查看:60
本文介绍了尝试在视图中查看Word文档(ASP.NET MVC)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我正在尝试使用ASP.NET MVC构建应用程序,其中我必须在视图中查看Word文档.我在网上进行了大量搜索,发现Microsoft.Office.Interop.Office可以用于此目的.以下是(我猜)当前代码中最重要的几行...

Hello

I am trying to build an application using ASP.NET MVC in which I have to view a word doc in a view. I searched a lot on the web and found that Microsoft.Office.Interop.Office can be used for this. The following are ( I guess ) the most important lines in the present code...

Application objWord = new Application();

objWord.Documents.Open(ref sourceFilePath, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing,ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);

objWord.Visible = false;

Microsoft.Office.Interop.Word.Document oDoc = objWord.ActiveDocument;

oDoc.SaveAs(ref savefilename, ref fltDocFormat, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);



我试图先将doc文件转换为htm格式,然后再使用iframe在视图中查看文档.

但是,当我调试时,在"Application objWord = new Application()"行中引发以下异常...

由于以下错误,检索具有CLSID {000209FF-0000-0000-C000-000000000046}的组件的COM类工厂失败:80040154未注册类(HRESULT的异常:0x80040154(REGDB_E_CLASSNOTREG)).

有人可以帮帮我吗.

谢谢.



I am trying to convert the doc file to htm format first, after which I will use iframe to view the document in the view.

But when I debug, the following exception is thrown at the "Application objWord = new Application()" line...

Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

Can some one please help me.

Thanks.

推荐答案

基于错误代码,看来根本没有在服务器上安装Word.为了使用互操作,必须先安装它.
Based on the error code looks like Word isn''t installed on the server at all. In order to use interop you must install it.


这篇关于尝试在视图中查看Word文档(ASP.NET MVC)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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