.net 读word中文字方法

Word.ApplicationClass app = null;
        Word.Document doc = null;
        object missing = System.Reflection.Missing.Value;
        object FileName = Server.MapPath("http://www.cnblogs.com/UpLoad/YJQX/YJYAGL/无标题文档002746.doc");//@"E:\学习试验项目\ReadFromWordDoc\test.doc";
        object readOnly = true;
        object isVisible = false;
        try
        {
            app = new Word.ApplicationClass();
            doc = app.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);
            string textString = doc.Content.Text;
            //Response.Write(textString);
            lblContent.Text = textString.ToString();
        }
        catch (Exception)
        {
            throw;
        }

posted @ 2009-09-24 13:19  mysun  阅读(268)  评论(0编辑  收藏  举报