Free Support Forum - aspose.com

Check out commented cells

hi Aspose.cells users,


Is there a simple way to get a list of all cells that have a comment attached to it ?

Obviously, I could open the file and loop through all cells to check the existence of a comment, but is there no simpler way, eg getting a collection of all cells that have comments

thanks - other ideas are welcome.

guido



Hi,


Well, there is not any specific APIs available, but you may do it very easily in your code. For example, you may iterate all the comments in a worksheet using Worksheet.Comment property, then, you may fill a list of Cell array for your needs, see the sample code below:

Sample code:

Workbook workbook = new Workbook(“e:\test\test_comments.xls”);
Worksheet worksheet = workbook.Worksheets[0];
List<Aspose.Cells.Cell> rangeList = new List<Aspose.Cells.Cell>();
foreach (Comment comment in worksheet.Comments)
{
string note = comment.Note;
//Get the comment cell.
Aspose.Cells.Cell cell = worksheet.Cells[comment.Row, comment.Column];
rangeList.Add(cell);
}
IEnumerator cells = rangeList.GetEnumerator();
while (cells.MoveNext())
{
Cell cell = cells.Current as Cell;
Debug.WriteLine(cell.Name);

}

Thank you.