C# 获取word批注信息
今天在Silverlight 应用程序中实现了 获取word文档批注信息 的功能。
在wcf服务继承接口类中编写的函数如下
[c-sharp] view plaincopy
/// <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;
}
其中wordComment.Range.Text 表示批注的内容
wordComment.Author 表示批注添加人
,温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/71190.html
- 上一篇:HDU 5266 bc# 43 LCA+跳表
- 下一篇:没有了