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

Free Support Forum - aspose.com

Unable to get or set alternative text for Comment shape

I am unable to get or set alternative text for a Comment shape.
I am using Aspose.Cells for Java 18.5.0

I have a couple of comments on cells in my test Excel document which have their alternative text set. When I try to read the alt text, it shows as blank.
After trying to set the alt text from the API, when I open up the Excel, I see that the alt text has not changed to the new one. What is worse, the original alt text has been replaced by the comment’s actual text!

Here is the code snippet. The Excel file used is attached (Comment.xlsx).

for (Shape shape : (Iterable<Shape>) worksheet.getShapes()) {
    String altText = shape.getAlternativeText();
    System.out.println("Comment alt text is: " + altText);

    String newAltText = "New description for my Comment.";
    System.out.println("Setting alt text to: " + newAltText);
    shape.setAlternativeText(newAltText);
}

The output is:

Comment alt text is: 
Setting alt text to: New description for my Comment.
Comment alt text is: 
Setting alt text to: New description for my Comment.

Screenshots attached:
InputExcel.PNG - Original Excel document with the Comment and its alt text displayed
OutputExcel.PNG - Aspose generated Excel with the Comment and its alt text displayed

Thanks.
Comment.zip (8.1 KB)
InputExcel.PNG (37.3 KB)
OutputExcel.PNG (37.8 KB)

@oraspose

Thanks for using Aspose APIs.

We were able to observe this issue as per your description and logged it in our database for investigation and for a fix. Once, the issue is resolved or we have some other news for you, we will let you know asap.

This issue has been logged as

  • CELLSJAVA-42647 - Unable to get or set alternative text for Comment shape

@oraspose,

This is to inform you that your issue has been fixed. After implementing QA and adding other extensions and fixes, we will soon provide a fixed version.

@oraspose

Thanks for using Aspose APIs.

Please download and try the following fix for your issue CELLSJAVA-42647 and let us know your feedback.

Get is fixed. Set is not fixed.
I expect the alt text for the comment to now show “New description for my Comment.”.
But it is same as the input document,

@oraspose

Thanks for using Aspose APIs.

We have tested your previous code and found, Set is also working fine. Please check the following code and its console output for your reference.

Java

Workbook wb = new Workbook(dirPath + "Comment.xlsx");

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

for (Shape shape : (Iterable<Shape>) worksheet.getShapes()) {
	String altText = shape.getAlternativeText();
	System.out.println("Comment alt text is: " + altText);

	String newAltText = "New description for my Comment.";
	System.out.println("Setting alt text to: " + newAltText);
	shape.setAlternativeText(newAltText);
}

System.out.println("--------------------------");

for (Shape shape : (Iterable<Shape>) worksheet.getShapes()) {
	String altText = shape.getAlternativeText();
	System.out.println("After changing: " + altText);
}

Console Output:

Comment alt text is: Text Box: Author:
This is the description of a cell that has a visible comment associated with the cell text.
Setting alt text to: New description for my Comment.
Comment alt text is: Author:
Here is the hidden comment which is visible only on mouse hover.
Setting alt text to: New description for my Comment.
--------------------------
After changing: New description for my Comment.
After changing: New description for my Comment.

The issues you have found earlier (filed as CELLSJAVA-42647) have been fixed in Aspose.Cells for Java 18.6. Please also see the document for your reference: https://docs.aspose.com/display/cellsjava/Installation