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
}
}