Estrai il testo dalla forma SmartArt Tipo di ingranaggio
Contents
[
Hide
]
Possibili scenari di utilizzo
Aspose.Cells può estrarre il testo dalla forma artistica intelligente del tipo di ingranaggio. Per fare ciò, devi prima convertire Smart Art Shape in Group Shape usando ilShape.getResultOfSmartArt() metodo. Quindi dovresti ottenere l’array di tutte le forme individuali che formano la forma del gruppo usando ilGroupShape.getGroupedShapes() metodo. Infine, puoi iterare tutte le singole forme una per una in un ciclo ed estrarre il loro testo usando ilForma.Testoproprietà.
Estrai il testo dalla forma SmartArt Tipo di ingranaggio
Il codice di esempio seguente carica il fileesempio di file Excelche contiene Gear Type Smart Art Shape. Quindi estrae il testo dalle sue singole forme come discusso sopra. Si prega di consultare l’output della console del codice fornito di seguito per un riferimento.
Codice d’esempio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
Uscita console
Gear Type Shape Text: Nice Gear Type Shape Text: Good Gear Type Shape Text: Excellent