We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Comments in Worksheet.getShapes()

Hi,


The way I’m working with cell comments at the moment is:

String path = “Comments.xlsx”;

Workbook workbook = new Workbook(path);

Worksheet worksheet = workbook.getWorksheets().get(0);

ShapeCollection shapes = worksheet.getShapes();
System.out.println(“Printing comments from ShapeCollection:”);

for (int i = 0; i < shapes.getCount(); i++) {
<span class=“Apple-tab-span” style=“font-family: “Courier New”; white-space: pre;”> <span style=“font-family: “Courier New”;”>System.out.println(shapes.get(i).getText());
}

The output:

Printing comments from ShapeCollection:
Cell A1 Comment
Cell A2 Comment
Cell A3 Comment
Shape Text
Button Text

I also found out about CommentCollection, so I’m thinking of switching to it for handling comments:

String path = “Comments.xlsx”;

Workbook workbook = new Workbook(path);

Worksheet worksheet = workbook.getWorksheets().get(0);

ShapeCollection shapes = worksheet.getShapes();

System.out.println(“Printing comments from CommentCollection:”);

CommentCollection comments = worksheet.getComments();

for (int i = 0; i < comments.getCount(); i++) {
System.out.println(comments.get(i).getCommentShape().getText());
}

The output:

Printing comments from CommentCollection:
Cell A1 Comment
Cell A2 Comment
Cell A3 Comment

What I’ve noticed from these outputs is that ShapeCollection has comments added to the beginning of the collection. In order to safely switch to using CommentCollection, I need your confirmation that comments always appear at the beginning of the ShapeCollection. Am I right about this?

Thanks,
Zeljko

Hi,


Thanks for your template file, sample code and details.

Yes, your understanding is correct.

Let us know if you still have any further comments or questions.

Thank you.