怎么获取word文档的属性信息!如:字体大小、颜色等。。

wang19918019 2013-01-07 05:03:06
如题。设计开发一word文档格式信息提取器,可提取出word文档的段落、图片等元素,并提取出各种元素的格式信息,如字体、字号、颜色、修饰等。
...全文
591 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wang19918019 2013-01-11
  • 打赏
  • 举报
回复
啊你这是我有 了。还有么
风一样的大叔 2013-01-10
  • 打赏
  • 举报
回复
   /// <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
            {
            }
            finally
            {
                wordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
            }
            return strWordComments;
        }
wang19918019 2013-01-10
  • 打赏
  • 举报
回复
我怎么没感觉啊?具体点好不好大哥
  • 打赏
  • 举报
回复
引用 4 楼 wang19918019 的回复:
求帮助啊。。。。
楼上说了很多了、亲
wang19918019 2013-01-08
  • 打赏
  • 举报
回复
求帮助啊。。。。
Vanishaway 2013-01-07
  • 打赏
  • 举报
回复

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();//段落格式

抛砖引玉
six-years 2013-01-07
  • 打赏
  • 举报
回复
wang19918019 2013-01-07
  • 打赏
  • 举报
回复
上贴的100分贴已经结贴!只要正确,不够的补。谢谢各位前辈解答啊

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧