Estrarre il testo dalla forma di Arte intelligente di tipo Gear
Possibili Scenari di Utilizzo
Aspose.Cells può estrarre il testo dalla forma di arte Smart Art dei tipi di ingranaggi. Per farlo, devi prima convertire la Forma di Arte Intelligente in Forma di Gruppo utilizzando il metodo Shape.getResultOfSmartArt(). Poi dovresti ottenere l’array di tutte le Forme Individuali che formano la Forma di Gruppo utilizzando il metodo GroupShape.getGroupedShapes(). Infine, puoi iterare tutte le Forme Individuali una per una in un ciclo ed estrarre il loro testo utilizzando la proprietà Shape.Text.
Estrarre il testo dalla forma SmartArt di tipo ingranaggio
Il seguente codice di esempio carica il file di Excel di esempio che contiene la Forma di Arte Smart Art dei tipi di ingranaggi. Quindi estrae il testo dalle sue forme individuali come discusso sopra. Si prega di vedere l’output console del codice riportato di seguito per riferimento.
Codice di Esempio
// 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 |
Output della console
Gear Type Shape Text: Nice Gear Type Shape Text: Good Gear Type Shape Text: Excellent