Извлечение текста из формы SmartArt типа Gear
Возможные сценарии использования
Aspose.Cells может извлекать текст из умной формы Gear Type Smart Art. Для этого сначала нужно преобразовать умную форму в групповую форму, используя метод Shape.GetResultOfSmartArt(). Затем следует получить массив всех индивидуальных форм, составляющих групповую форму, с помощью метода GroupShape.GetGroupedShapes(). Наконец, можно перебрать все индивидуальные формы по одной в цикле и извлечь их текст, используя свойство Shape.Text.
Извлечение текста из формы SmartArt с шестеренчатым типом
В следующем примере кода загружается образец файла Excel, содержащий умную форму Gear Type Smart Art. Затем извлекается текст из ее индивидуальных форм, как обсуждалось выше. Пожалуйста, ознакомьтесь с выводом консоли в приведенном ниже примере кода в качестве примера.
Образец кода
// 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 |
Вывод в консоль
Gear Type Shape Text: Nice
Gear Type Shape Text: Good
Gear Type Shape Text: Excellent