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 intelligente di tipo Gear. 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 compongono la Forma di gruppo utilizzando il metodo GroupShape.GetGroupedShapes(). Infine, puoi iterare tutte le forme individuali una per una in un loop 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 intelligente di tipo Gear. Quindi estrae il testo dalle sue forme individuali come discusso in precedenza. Si prega di consultare l’output della console del codice fornito di seguito per riferimento.
Codice di Esempio
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Load sample Excel file containing gear type smart art shape. | |
Workbook wb = new Workbook("sampleExtractTextFromGearTypeSmartArtShape.xlsx"); | |
// Access first worksheet. | |
Worksheet ws = wb.Worksheets[0]; | |
// Access first shape. | |
Aspose.Cells.Drawing.Shape sh = ws.Shapes[0]; | |
// Get the result of gear type smart art shape in the form of group shape. | |
Aspose.Cells.Drawing.GroupShape gs = sh.GetResultOfSmartArt(); | |
// Get the list of individual shapes consisting of group shape. | |
Aspose.Cells.Drawing.Shape[] shps = gs.GetGroupedShapes(); | |
// Extract the text of gear type shapes and print them on console. | |
for (int i = 0; i < shps.Length; i++) | |
{ | |
Aspose.Cells.Drawing.Shape s = shps[i]; | |
if (s.Type == Aspose.Cells.Drawing.AutoShapeType.Gear9 || s.Type == Aspose.Cells.Drawing.AutoShapeType.Gear6) | |
{ | |
Console.WriteLine("Gear Type Shape Text: " + s.Text); | |
} | |
}//for |
Output della console
Gear Type Shape Text: Nice
Gear Type Shape Text: Good
Gear Type Shape Text: Excellent