本文介绍了如何向网页显示word文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Microsoft.Office.Interop.Word;
public partial class Articles : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Microsoft.Office.Interop.Word.Application objWordApp = new Microsoft.Office.Interop.Word.Application();
//ACCESSING THE WORD FILE PATH
object objWordFile = Server.MapPath("Images\\water crisis.doc");
object objNull = System.Reflection.Missing.Value;
Document WordDoc = objWordApp.Documents.Open(
ref objWordFile, ref objNull, ref objNull,
ref objNull, ref objNull, ref objNull,
ref objNull, ref objNull, ref objNull,
ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull);
WordDoc.ActiveWindow.Selection.WholeStory();
WordDoc.ActiveWindow.Selection.Copy();
string strWordText = WordDoc.Content.Text;
WordDoc.Close(ref objNull, ref objNull, ref objNull);
objWordApp.Quit(ref objNull, ref objNull, ref objNull);
// Asssigning word file value to bind the div
divfordisplaywordcontent.InnerHtml = strWordText;
}
}
推荐答案
这篇关于如何向网页显示word文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!