我觉得你这样做没有必要吧,你只是要显示WORD文档相应的内容到指定的TextBox中,你可以直接采用OWC来操作这个WORD文档!这样你可以读出相应的内容就好..............
解决方案 »
- 如何设置AutocompleteExtender控件输出的文本与文本框边框对齐!
- C# MVC 中获取checkboxfor 的值
- 紧急求救!!!!! 请问客户端javascript如何获取checkboxlist的每个item的value,希望上午就能搞定哦...
- 新做的网站,大家拍砖
- 如何弹出提示框?
- ie6.0sp1下框架下打印出错,ie5正常----救命啊,验收关键(100分)
- 难度比较高的文件夹上传问题,请高手帮忙!
- !!!!高手帮我分析一断程序,应该不是会很难!!!!!!
- 如何能让HtmlSelect控件中的第一条数据成为 selected 状态?
- asp.net实现在线文本编辑器,扩展功能!
- 本人现有分848,我有两个问题,回答出来,我愿给他所有的分。(这里就不出分,因为最多100)
- 关于session的问题
using System;
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.HtmlControls;
using Office;namespace aspxWebcs
{
/// <summary>
/// WordToHtml 的摘要说明。
/// 首先要添加引用:Microsoft Word 9.0 Object Library
/// </summary>
public class WordToHtml : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
Word.ApplicationClass word = new Word.ApplicationClass();
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.BindingFlags.InvokeMethod, 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.BindingFlags.InvokeMethod,
null, doc, new object[]{saveFileName, Word.WdSaveFormat.wdFormatFilteredHTML});
///其它格式:
///wdFormatHTML
///wdFormatDocument
///wdFormatDOSText
///wdFormatDOSTextLineBreaks
///wdFormatEncodedText
///wdFormatRTF
///wdFormatTemplate
///wdFormatText
///wdFormatTextLineBreaks
///wdFormatUnicodeText
docType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod,
null, doc, new object[]{saveFileName, Word.WdSaveFormat.wdFormatHTML}); // 退出 Word
wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod,
null, word, null);
}#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
如果你转化成为XML文档过后,可以通过XmlDocument来操作它,读出你想要的格式来吧
”------我用这个办法已经实现了,但是我们头说处理个WORD文档不必用数据库,非让我用其它的办法
2.or save word to xml format, then handle----这个我用过了,可是不知道,然后如何处理XML liuyong_lll(孤醉)大哥“直接采用OWC来操作这个WORD文档!“这是个好的建议,我还没想到,就是不知道如何去用,能再指点一下吗 再次感谢各位,我觉得这个问题是挺有挑战性的,希望能再给我写指点,多谢了
”------我用这个办法已经实现了,但是我们头说处理个WORD文档不必用数据库,非让我用其它的办法
2.or save word to xml format, then handle----这个我用过了,可是不知道,然后如何处理XML liuyong_lll(孤醉)大哥“直接采用OWC来操作这个WORD文档!“这是个好的建议,我还没想到,就是不知道如何去用,能再指点一下吗 再次感谢各位,我觉得这个问题是挺有挑战性的,希望能再给我写指点,多谢了
OWC用的还是比较多,特别是做报表的时候
我做的时候例子也没有,只有《Microsoft Office Web 组件对象模型参考》,楼主如果要的话,我就发给你