GearタイプのSmartArt Shapeからテキストを抽出する(C++)
Contents
[
Hide
]
可能な使用シナリオ
Aspose.Cells for C++は、GearタイプのSmartArt Shapeからテキストを抽出できます。これを行うためには、以下の手順に従います:
- SmartArt ShapeをShape::GetResultOfSmartArt()メソッドを用いてグループシェイプに変換します。
- GroupShape::GetGroupedShapes()メソッドを使って、グループシェイプを構成するすべての個別シェイプを取得します。
- 各個別シェイプをループしながら、GetText()メソッドを用いてテキストを抽出します。
ギアタイプのスマートアートシェイプからテキストを抽出する
以下のサンプルコードは、GearタイプのSmartArt Shapeを含むサンプルExcelファイルを読み込み、その個別シェイプからテキストを抽出します。結果はコンソール出力を参照してください。
サンプルコード
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
using namespace Aspose::Cells::Drawing;
int main()
{
Aspose::Cells::Startup();
// Load sample Excel file containing gear type smart art shape
U16String inputFile(u"sampleExtractTextFromGearTypeSmartArtShape.xlsx");
Workbook wb(inputFile);
// Access first worksheet
Worksheet ws = wb.GetWorksheets().Get(0);
// Access first shape
Shape sh = ws.GetShapes().Get(0);
// Get SmartArt result as group shape
GroupShape gs = sh.GetResultOfSmartArt();
// Get grouped shapes collection
Vector<Shape> shps = gs.GetGroupedShapes();
// Iterate through shapes and check gear types
for (int i = 0; i < shps.GetLength(); i++)
{
Shape s = shps[i];
AutoShapeType shapeType = s.GetType();
if (shapeType == AutoShapeType::Gear9 || shapeType == AutoShapeType::Gear6)
{
std::cout << "Gear Type Shape Text: " << s.GetText().ToUtf8() << std::endl;
}
}
Aspose::Cells::Cleanup();
return 0;
}
コンソール出力
Gear Type Shape Text: Nice
Gear Type Shape Text: Good
Gear Type Shape Text: Excellent