zoukankan      html  css  js  c++  java
  • C# 获取word批注信息

    今天在Silverlight 应用程序中实现了 获取word文档批注信息 的功能。

    在wcf服务继承接口类中编写的函数如下

    [c-sharp] view plaincopy
     
    1. /// <summary>  
    2. /// 获取word批注信息  
    3. /// </summary>  
    4. /// <param name="filePath">文档路径</param>  
    5. /// <returns>批注信息</returns>  
    6. public string GetWordNotes(string filePath)  
    7. {  
    8.     object Nothing = System.Reflection.Missing.Value;  
    9.     string strWordComments = string.Empty;  
    10.     Microsoft.Office.Interop.Word.Application wordApp = new Application();  
    11.     wordApp.Visible = false;  
    12.     Document wordDoc = new Document();  
    13.     wordDoc = wordApp.Documents.Open(filePath, Nothing, Nothing, Nothing, Nothing,  
    14.         Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing);  
    15.     try  
    16.     {  
    17.         foreach (Comment wordComment in wordDoc.Comments)  
    18.         {  
    19.             strWordComments += wordComment.Range.Text+" 作者:"+wordComment.Author+" 创建日期:"+wordComment.Date;  
    20.         }  
    21.     }  
    22.     catch  
    23.     {  
    24.     }  
    25.     finally  
    26.     {  
    27.         wordDoc.Close(ref Nothing, ref Nothing, ref Nothing);  
    28.     }  
    29.     return strWordComments;  
    30. }  

    其中wordComment.Range.Text 表示批注的内容

    wordComment.Author 表示批注添加人

    wordComment.Date 表示添加批注的时间

  • 相关阅读:
    vue父子组件传值的方式
    定时任务写法
    仅仅为笔记
    consul剔除某个服务
    mybatis批量查询
    一次eureka的事故
    feign的工作原理
    JVM优化
    threadlocal应用
    秋招总结
  • 原文地址:https://www.cnblogs.com/Alex80/p/4560223.html
Copyright © 2011-2022 走看看