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