Free Support Forum - aspose.com

Unable to set alternative text for SmartArt shape

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

After trying to set the alt text, when I open up the Excel, I see that the original alt text has not changed to the new one.

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

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

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

The output is:
Shape alt text is: Description of a double arrow.
Setting alt text to: New description for my SmartArt.

Although I am calling the set, the alt text is not getting set in the saved Excel document. Screenshot attached (OutputExcel.PNG).

Thanks.
SmartArt.zip (14.0 KB)
OutputExcel.PNG (39.5 KB)

@oraspose,

Thanks for the template file and sample code.

After an initial test, I am able to observe the issue as you mentioned by using your sample code with your template file. I found alternative text for SmartArt shape is not updated in the output Excel file:
e.g
Sample code:

Workbook wb = new Workbook("f:\\files\\smartart.xlsx"); 

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

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

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

wb.save("f:\\files\\out1.xlsx");

I have logged a ticket with an id “CELLSJAVA-42632” for your issue. We will look into it soon.
Once we have an update on it, we will let you know here.

@oraspose,

This is to inform you that we have fixed your issue "CELLSJAVA-42632 " now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

Once the fix is available for public use, we will share the Download link here.

Thank you. Can you provide a code workaround which we can use, until we migrate to the version having the fix?

@oraspose,

Could you try our latest version/fix: Aspose.Cells for Java v18.5.2:

Your issue should be fixed in it as I tested.

Let us know your feedback.

@oraspose

We recommend you to kindly download and try the following (latest) fix as it has more enhancements.

Let us know your feedback.

I downloaded 18.5.2 and 18.5.4 and verified that the issue is fixed. I am able to see the alt-text being set for the SmartArt. Thanks!

Until we migrate to the version having the fix, is there a code workaround which we can use?

@oraspose,

I am afraid, there is no workaround to cope with your issue, so you got to upgrade to latest fix to figure out your issue.

The issues you have found earlier (filed as CELLSJAVA-42632) 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