日期:2014-05-17  浏览次数:21042 次

怎么获取word文档的属性信息!如:字体大小、颜色等。。
如题。设计开发一word文档格式信息提取器,可提取出word文档的段落、图片等元素,并提取出各种元素的格式信息,如字体、字号、颜色、修饰等。

------解决方案--------------------
获取word文档所有信息
------解决方案--------------------

Word._Document oDoc;//文档对象
object path = @"E:\XXX.docx";//地址
oDoc = oWord.Documents.Open(ref path, ref oMissing, ref oReadOnly, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);


有了对象之后就可以进行操作了:


Word.Table tab = oDoc.Tables[1];//获取表

String format = oDoc.Paragraphs.Format.ToString();//段落格式



抛砖引玉
------解决方案--------------------
引用:
求帮助啊。。。。

楼上说了很多了、亲
------解决方案--------------------
   /// <summary>
        /// 获取word批注信息
        /// </summary>
        /// <param name="filePath">文档路径</param>
        /// <returns>批注信息</returns>
        public string GetWordNotes(string filePath)
        {
            object Nothing = System.Reflection.Missing.Value;
            string strWordComments = string.Empty;
            Microsoft.Office.Interop.Word.Application wordApp = new Application();
            wordApp.Visible = false;
            Document wordDoc = new Document();
            wordDoc = wordApp.Documents.Open(filePath, Nothing, Nothing, Nothing, Nothing,
                Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing);
            try
            {
                foreach (Comment wordComment in wordDoc.Comments)
                {
                    strWordComments += wordComment.Range.Text+" 作者:"+wordComment.Author+" 创建日期:"+wordComment.Date;
                }
            }
            catch