Extraiga texto de la forma SmartArt de tipo de engranaje
Contents
[
Hide
]
Posibles escenarios de uso
Aspose.Cells puede extraer texto de Gear Type Smart Art Shape. Para hacerlo, primero debe convertir Smart Art Shape a Group Shape usando elForma.getResultOfSmartArt() método. Luego, debe obtener la matriz de todas las Formas individuales que forman la Forma de grupo usando elFormaGrupo.getFormasAgrupadas() método. Finalmente, puede iterar todas las formas individuales una por una en un bucle y extraer su texto usando elForma.Textopropiedad.
Extraiga texto de la forma SmartArt de tipo de engranaje
El siguiente código de ejemplo carga elejemplo de archivo de Excelque contiene Gear Type Smart Art Shape. Luego extrae el texto de sus formas individuales como se discutió anteriormente. Consulte la salida de la consola del código que se proporciona a continuación para obtener una referencia.
Código de muestra
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 |
Salida de consola
Gear Type Shape Text: Nice Gear Type Shape Text: Good Gear Type Shape Text: Excellent