如何使用OpenXML方法读取Excel文件中的注释 [英] How to Read Comments in an Excel File using OpenXML approach
本文介绍了如何使用OpenXML方法读取Excel文件中的注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我的项目中要求阅读Excel文档中的注释并处理这些注释.
我正在使用Open XML方法执行此操作.
任何人都可以提出实现此目标的方法吗?
谢谢和问候,
YKK Reddy
Hi All,
I have a requirement in my project to read comments in an excel document and process those comments.
I am using Open XML approach to do this.
Can anyone suggest a way to achieve this ?
Thanks and Regards,
YKK Reddy
推荐答案
我使用下面提到的代码解决了.
SpreadsheetDocument spreadSheetDocument = SpreadsheetDocument.Open(/* Excel文件名*/,true);
Hi,
i solved using the below mentioned code.
SpreadsheetDocument spreadSheetDocument = SpreadsheetDocument.Open(/* Excel File Name */, true);
WorkbookPart workBookPart = spreadSheetDocument.WorkbookPart;
List<string> lstComments = new List<string>();
foreach (WorksheetPart sheet in workBookPart.WorksheetParts)
{
foreach (WorksheetCommentsPart commentsPart in sheet.GetPartsOfType<WorksheetCommentsPart>())
{
foreach (Comment comment in commentsPart.Comments.CommentList)
{
lstComments.Add(comment.InnerText);
}
}
}
lstComments包含所有工作表中的注释.我们还可以针对特定的表进一步对其进行优化.
谢谢和问候,
Kishor Reddy
lstComments contains the Comments present in all the sheets. We can further refine it for a particular sheet also.
Thanks and Regards,
Kishor Reddy
此链接可能对您有帮助
http://msdn.microsoft.com/en-us/library/ff921204.aspx [ ^ ]
读取和写入Open XML文件(MS Office 2007) [ ^ ]
----
使用Open XML SDK 2.0检索Excel 2010工作簿中单元格的值 [ ^ ]
Office Open XML格式:检索Excel 2007单元格值 [ ^ ]
Hi,
this links may help you
http://msdn.microsoft.com/en-us/library/ff921204.aspx[^]
Read and write Open XML files (MS Office 2007)[^]
----
Retrieving the Values of Cells in Excel 2010 Workbooks by Using the Open XML SDK 2.0[^]
Office Open XML Formats: Retrieving Excel 2007 Cell Values[^]
这篇关于如何使用OpenXML方法读取Excel文件中的注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文