如何在c#4.0中显示word文件 [英] how to show word file in c# 4.0

查看:102
本文介绍了如何在c#4.0中显示word文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,





新的开发部分需要在VS2008中显示word文件以及如何能够穿鞋单词文件我使用了以下代码plz使用Word = Microsoft.Office.Interop.Word;

为我提供了必要的









公共部分类SE_SEIT_PSOOP_Default:System.Web.UI.Page

{

protected void Page_Load(object sender,EventArgs e)

{

对象缺失= System.Reflection.Missing.Value;

object readOnly = false;

object isVisible = true;

object fileName =〜/ SE / SEIT / DSF / E-notes / UNIT I I.docx;

Microsoft.Office.Interop.Word.ApplicationClass applicationWord = new Microsoft.Office.Interop.Word.ApplicationClass();

Microsoft.Office.Interop.Word.Document modelloBusta =新的Microsoft.Office.Interop.Word.Document();


尝试

{



modelloBusta = applicationWord.Documents.Open(ref fileName,ref missing,ref readOnly, ref ref缺失,ref缺失,ref缺失,ref缺失,ref缺失,ref缺失,ref缺失,ref缺失,ref isVisible,ref missing,ref missing,ref missing,ref missing);

modelloBusta。激活();







}

catch(异常eccezione)

{

Console.Write(eccezione);

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



}

}

}

Dear All,


Am new in development section and need to show the word file in VS2008 and how m able to shoe the word file i have used the following code plz provide me the needfull

using Word = Microsoft.Office.Interop.Word;
.
.

public partial class SE_SEIT_PSOOP_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
object missing = System.Reflection.Missing.Value;
object readOnly = false;
object isVisible = true;
object fileName = "~/SE/SEIT/DSF/E-notes/UNIT I I.docx";
Microsoft.Office.Interop.Word.ApplicationClass applicationWord = new Microsoft.Office.Interop.Word.ApplicationClass();
Microsoft.Office.Interop.Word.Document modelloBusta = new Microsoft.Office.Interop.Word.Document();

try
{

modelloBusta = applicationWord.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, ref missing);
modelloBusta.Activate();



}
catch (Exception eccezione)
{
Console.Write(eccezione);
modelloBusta.Application.Quit(ref missing, ref missing, ref missing);

}
}
}

推荐答案

Microsoft警告不要在服务器设置中使用Office Interop:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2 [<一个href =http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2\"target =_ blanktitle =新窗口> ^ ],

http://support.microsoft.com/kb/257757/en-us [ ^ ]。



基本上,您需要将一些办公文档映射到HTML并显示它。



如果您只想与某些办公室合作文档,您可以使用Open XML SDK:

http:/ /www.microsoft.com/en-us/download/details.aspx?id=30425 [ ^ ]。



这样,您可以支持新的基于XML的Office格式(如.DOCX,.XLSX),ECMA-376标准:

http:// en .wikipedia.org / wiki / Microsoft_Office_XML_formats [ ^ ] ,

http://en.wikipedia.org/wiki/Office_Open_XML [ ^ ]。



这样,您可以在没有安装Office的情况下工作。此外,第三方软件支持这些文档。请查看我过去的答案:

将Office文档转换为PDF而不互操作 [ ^ ],
需要一个相当独特的WPF文本编辑器控件 [ ^ ],

您好如何使用c#.net 在Windows应用程序中显示word文件[ ^ ],

阅读没有使用Interop.word dll的word文件...不想在IIS中安装单词。 [ ^ ]。



这是另一种选择: http://npoi.codeplex.com/ [ ^ ]。



-SA
Microsoft warns against the use of Office Interop in server settings:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2[^],
http://support.microsoft.com/kb/257757/en-us[^].

Basically, you need to map some office documents to HTML and show it.

If you only want to work with some office documents, you can use Open XML SDK:
http://www.microsoft.com/en-us/download/details.aspx?id=30425[^].

This way, you can support new XML-based Office formats (such as .DOCX, .XLSX), ECMA-376 standard:
http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats[^],
http://en.wikipedia.org/wiki/Office_Open_XML[^].

This way, you can work without Office installed. Also, the documents are supported by 3rd-party software. Please see my past answers:
Convert Office-Documents to PDF without interop[^],
Need a rather unique WPF text editor control[^],
Hi how can i display word file in windows application using c#.net[^],
Read a word file without using Interop.word dll...Do not want to install word in IIS..[^].

This is another option: http://npoi.codeplex.com/[^].

—SA


这篇关于如何在c#4.0中显示word文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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