从齿轮型智能图形中提取文本

可能的使用场景

Aspose.Cells 能够从 Gear Type Smart Art Shape 中提取文本。为此,您应该首先使用 Shape.getResultOfSmartArt() 方法将 Smart Art Shape 转换为 Group Shape。然后使用 GroupShape.getGroupedShapes() 方法获取形成组合形状的所有 Individual Shapes 的数组。最后,您可以在循环中逐个迭代所有 Individual Shapes 并使用 Shape.Text 属性提取它们的文本。

从齿轮型智能图形中提取文本

以下示例代码加载包含 齿轮类型智能图形 的 示例Excel文件。然后提取其单个图形的文本,如上所述。请参考下面给出的代码的控制台输出。

示例代码

// 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

控制台输出

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