歯車の種類の SmartArt 図形からテキストを抽出する

考えられる使用シナリオ

Aspose.Cells は、歯車型スマート アート シェイプからテキストを抽出できます。そのためには、まず、Smart Art Shape を Group Shape に変換する必要があります。Shape.GetResultOfSmartArt()方法。次に、グループ シェイプを形成するすべての個々のシェイプの配列を取得する必要があります。GroupShape.GetGroupedShapes()方法。最後に、すべての個々のシェイプをループで 1 つずつ反復し、シェイプ.テキスト財産。

歯車の種類の SmartArt 図形からテキストを抽出する

次のサンプル コードは、サンプル Excel ファイルギアタイプのスマートアートシェイプを収録。次に、上記のように個々の形状からテキストを抽出します。以下のコードのコンソール出力を参照してください。

サンプルコード

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