Extract Text from the Gear Type SmartArt Shape

Possible Usage Scenarios

Aspose.Cells can extract text from the Gear Type Smart Art Shape. In order to do so, you should first convert Smart Art Shape to Group Shape using the Shape.getResultOfSmartArt() method. Then you should get the array of all the Individual Shapes forming the Group Shape using the GroupShape.getGroupedShapes() method. Finally, you can iterate all of the Individual Shapes one by one in a loop and extract their text using the Shape.Text property.

Extract Text from the Gear Type SmartArt Shape

The following sample code loads the sample Excel file that contains Gear Type Smart Art Shape. It then extracts the text from its individual shapes as discussed above. Please see the console output of the code given below for a reference.

Sample Code

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// Load sample Excel file containing gear type smart art shape.
Workbook wb = new Workbook(srcDir + "sampleExtractTextFromGearTypeSmartArtShape.xlsx");
// Access first worksheet.
Worksheet ws = wb.getWorksheets().get(0);
// Access first shape.
Shape sh = ws.getShapes().get(0);
// Get the result of gear type smart art shape in the form of group shape.
GroupShape gs = sh.getResultOfSmartArt();
// Get the list of individual shapes consisting of group shape.
Shape[] shps = gs.getGroupedShapes();
// Extract the text of gear type shapes and print them on console.
for (int i = 0; i < shps.length; i++)
{
Shape s = shps[i];
if (s.getType() == AutoShapeType.GEAR_9 || s.getType() == AutoShapeType.GEAR_6)
{
System.out.println("Gear Type Shape Text: " + s.getText());
}
}//for

Console Output

Gear Type Shape Text: Nice Gear Type Shape Text: Good Gear Type Shape Text: Excellent