Extrahieren Sie Text aus der SmartArt-Form vom Typ Zahnrad

Mögliche Nutzungsszenarien

Aspose.Cells kann Text aus der Gear Type Smart Art Shape extrahieren. Um dies zu tun, sollten Sie zuerst Smart Art Shape mithilfe von in Group Shape umwandelnShape.getResultOfSmartArt() Methode. Dann sollten Sie das Array aller individuellen Formen erhalten, die die Gruppenform bilden, indem Sie die verwendenGroupShape.getGroupedShapes() Methode. Schließlich können Sie alle einzelnen Formen nacheinander in einer Schleife durchlaufen und ihren Text mithilfe von extrahierenForm.TextEigentum.

Extrahieren Sie Text aus der SmartArt-Form vom Typ Zahnrad

Der folgende Beispielcode lädt dieBeispiel-Excel-Dateidas Gear Type Smart Art Shape enthält. Dann extrahiert es den Text aus seinen einzelnen Formen, wie oben besprochen. Bitte sehen Sie sich die Konsolenausgabe des unten angegebenen Codes als Referenz an.

Beispielcode

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

Konsolenausgabe

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