ギア型スマートアート形状からテキストを抽出

可能な使用シナリオ

Aspose.Cellsはギア型スマートアート形状からテキストを抽出できます。そのためには、まずSmart Art ShapeをGroup Shapeに変換し、GroupShape.getGroupedShapes() メソッドを使用してグループ形状を形成するすべての個々の形状の配列を取得します。最後に、ループ内で個々の形状を一つずつ反復処理し、Shape.Textプロパティを使用してテキストを抽出します。

ギアタイプのスマートアートシェイプからテキストを抽出する

次のサンプルコードでは、Gear Type Smart Art Shape を含む サンプルExcelファイル を読み込み、その個々の図形からテキストを抽出します。参照のために、以下のコードのコンソール出力をご覧ください。

サンプルコード

// 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