ギア型スマートアート形状からテキストを抽出
可能な使用シナリオ
Aspose.Cellsは、ギアタイプのスマートアートシェイプからテキストを抽出することができます。そのためには、まずスマートアートシェイプをShape.GetResultOfSmartArt()メソッドを使用してグループ形状に変換する必要があります。次に、GroupShape.GetGroupedShapes()メソッドを使用してグループ形状を構成する個々の形状の配列を取得します。最後に、個々の形状をループで一つずつ取得し、Shape.Textプロパティを使用してそのテキストを抽出することができます。
ギアタイプのスマートアートシェイプからテキストを抽出する
以下のサンプルコードは、上記で説明したように、Gear Type Smart Art Shapeを含むsample Excel fileをロードし、その個々の形状からテキストを抽出します。以下は、サンプルコードのコンソール出力です。
サンプルコード
// 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