首页 > 编程知识 正文

html转换成word,word怎么转换到当前页面

时间:2023-05-05 08:44:28 阅读:164260 作者:2783

WordToHtml.aspx.cs

使用系统;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using system.web.ui.html controls; WordToHtml.aspx.cs

使用系统;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using system.web.ui.html controls;

使用偏移;

namespace aspxWebcs

{

//

///WordToHtml的摘要说明。

//首先添加引用。 Microsoft word 9.0对象库

///

publicclasswordtohtml 3360 system.web.ui.page

{

privatevoidpage _ load (object sender,System.EventArgs e ) )。

{

//在此处放置用户代码以初始化页面

word.applicationclassword=new word.application class (;

Type wordType=word.GetType (;

word.documents docs=word.documents;

//打开文件

Type docsType=docs.GetType (;

object filename=' d :\ tmp\ AAA.doc ';

word.document doc=(word.document ) docstype.invokemember ) ' open ',

system.reflection.binding flags.invoke method,null,docs,new Object[] {fileName,true,true};

//转换格式并另存为

Type docType=doc.GetType (;

object savefilename=' d :\ tmp\ AAA.html ';

Microsoft Word 9 Object Library的写法如下所示。 10的话,可能会写如下。

/*

docType.InvokeMember('SaveAs ',system.reflection.binding flags.invoke method,

null,doc,new object[]{saveFileName,word.wdsaveformat.wdformatfilteredhtml };

*/

//其他格式:

///wdFormatHTML

///wdFormatdocument

///wdFormatDOSText

///wdFormatDOSTextLineBreaks

///wdFormatEncodedText

///wdFormatRTF

///wdFormatTemplate

///wdFormatText

///wdFormatTextLineBreaks

///wdFormatUnicodeText

docType.InvokeMember('SaveAs ',system.reflection.binding flags.invoke method,

null,doc,new object[]{saveFileName,word.wdsaveformat.wdformathtml };

退出Word

wordtype.invokemember('quit ',system.reflection.binding flags.invoke method,

空,word,null;

}

#region Web表单设计器生成的代码

overrideprotectedvoidoninit (eventargs e ) )。

{

//

//codegen : ASP.NET web窗体设计器需要此调用。

//

初始化组件(;

base.oninit(e );

}

///

//设计器支持所需的方法-不在代码编辑器中修改

//本方法的内容。

///

私有语音初始化组件(

{

this.load=new system.eventhandler (this.page _ load;

}

#endregion

}

}

使用偏移;

namespace aspxWebcs

{

///

///WordToHtml的摘要说明。

//首先添加引用。 Microsoft word 9.0对象库

///

publicclasswordtohtml 3360 system.web.ui.page

{

privatevoidpage _ load (object sender,System.EventArgs e ) )。

{

//在此处放置用户代码以初始化页面

word.applicationclassword=new word.application class (;

Type wordType=word.GetType (;

word.documents docs=word.documents;

//打开文件

Type docsType=docs.GetType (;

object filename=' d :\ tmp\ AAA.doc ';

word.document doc=(word.document ) docstype.invokemember ) ' open ',

system.reflection.binding flags.invoke method,null,docs,new Object[] {fileName,true,true};

//转换格式并另存为

Type docType=doc.GetType (;

object savefilename=' d :\ tmp\ AAA.html ';

Microsoft Word 9 Object Library的写法如下所示。 10的话,可能会写如下。

/*

docType.InvokeMember('SaveAs ',system.reflection.binding flags.invoke method,

null,doc,new object[]{saveFileName,word.wdsaveformat.wdformatfilteredhtml };

*/

//其他格式:

///wdFormatHTML

///wdFormatdocument

///wdFormatDOSText

///wdFormatDOSTextLineBreaks

///wdFormatEncodedText

///wdFormatRTF

///wdFormatTemplate

///wdFormatText

///wdFormatTextLineBreaks

///wdFormatUnicodeText

docType.InvokeMember('SaveAs ',system.reflection.binding flags.invoke method,

null,doc,new object[]{saveFileName,word.wdsaveformat.wdformathtml };

退出Word

wordtype.invokemember('quit ',system.reflection.binding flags.invoke method,

空,word,null;

}

#region Web表单设计器生成的代码

overrideprotectedvoidoninit (eventargs e ) )。

{

//

//codegen : ASP.NET web窗体设计器需要此调用。

//

初始化组件(;

base.oninit(e );

}

///

//设计器支持所需的方法-不在代码编辑器中修改

//本方法的内容。

///

私有语音初始化组件(

{

this.load=new system.eventhandler (this.page _ load;

}

#endregion

}

}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。