无需安装MS Office的Microsoft.Office.Interop.Word [英] Microsoft.Office.Interop.Word without installing MS Office
本文介绍了无需安装MS Office的Microsoft.Office.Interop.Word的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Web应用程序Microsoft.Office.Interop.Word无法在服务器上运行.但是在本地计算机上运行良好.该应用程序托管在arvixe中.我想在文本框中显示文档(即word,PDF等).在本地计算机上的工作很流畅,但在实时状态下却是一个空文本框.为此,在.Net.My VB.Net代码中开发的应用程序如下.
Hi,
Web application Microsoft.Office.Interop.Word not working on the server.But it works fine in local machine. The application hosted in arvixe. I want to show a document(which is word, PDFs...etc) in a text box. The working in local machine is smooth but in live it is empty text box.The application developed in .Net.My VB.Net code for this purpose is given below.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Session("r_id") Is Nothing Then
iframe.Visible = False
Text_resume.Visible = False
Dim resume_name As String = Session("r_id") 'Server.HtmlEncode(Request.QueryString("r_id"))
Dim filepath As String = resume_name
Dim fileextention As String = Path.GetExtension(filepath)
If Not fileextention = ".pdf" Then
Text_resume.Visible = True
Dim realpath As String = MapPath("../jobseeker/Resume/" + filepath)
readFileContent(realpath)
Else
Dim realpath As String = "../jobseeker/Resume/" + filepath
iframe.Visible = True
iframe.Disabled = True
iframe.Attributes.Add("src", realpath & "?docId=456#toolbar=0")
End If
End If
lbl_check.Text = _path
End Sub
Private Sub readFileContent(ByVal path As String)
Try
Dim wordApp As New ApplicationClass()
Dim file As Object = path
_path = path
Dim nullobj As Object = System.Reflection.Missing.Value
Dim doc As Microsoft.Office.Interop.Word.Document = wordApp.Documents.Open(file, nullobj, nullobj, nullobj, nullobj, nullobj, _
nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, _
nullobj, nullobj, nullobj, nullobj)
doc.ActiveWindow.Selection.WholeStory()
doc.ActiveWindow.Selection.Copy()
Dim sFileText As String = doc.Content.Text
doc.Close(nullobj, nullobj, nullobj)
wordApp.Quit(nullobj, nullobj, nullobj)
Text_resume.Text = sFileText.ToString()
Catch ex As Exception
'alert.show_mssg(panel_mssg, lbl_mssg, "mssg_fail", "Your enquiries has been inserted successfully")
End Try
End Sub
在此先感谢.
Muhammed Haris K
Thanking in Advance.
Muhammed Haris K
推荐答案
在未安装Office的情况下无法使用Interop库.这是Microsoft的要求,因此,即使您知道如何做,也将违反EULA.有一些替代方法(Aspose,OOXML SDK等)可能有用,但要在服务器上使用Interop,则需要安装Office.
参考文献:
http://stackoverflow.com/questions/4724765/manipulating-word-documents-on-server-without-office-office-installed-asp-net [ http://social.msdn.microsoft.com/Forums/是/innovateonoffice/thread/973ce94f-5235-4be9-a2b1-51ba7d35e1f3 [
You cannot use the Interop libraries without Office installed. This is a requirement from Microsoft, so even if you figured out how to do it you would be violating the EULA. There are alternatives (Aspose, OOXML SDK, etc.) that might be useful but to use Interop on the server, you need to install Office.
References:
http://stackoverflow.com/questions/4724765/manipulating-word-documents-on-server-without-office-installed-asp-net[^]
http://social.msdn.microsoft.com/Forums/is/innovateonoffice/thread/973ce94f-5235-4be9-a2b1-51ba7d35e1f3[^]
如何为此目的使用Aspose,OOXML SDK?
在此先感谢.
穆罕默德·哈里斯(Muhammed Haris K)
How can i use Aspose,OOXML SDK for this purpose?
Thanking in Advance.
Muhammed Haris K
这篇关于无需安装MS Office的Microsoft.Office.Interop.Word的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文