Extract Text from the Gear Type SmartArt Shape with C++

Possible Usage Scenarios

Aspose.Cells for C++ can extract text from the Gear Type SmartArt Shape. To achieve this, follow these steps:

  1. Convert SmartArt Shape to Group Shape using the Shape::GetResultOfSmartArt() method.
  2. Retrieve all individual shapes forming the Group Shape using the GroupShape::GetGroupedShapes() method.
  3. Iterate through each individual shape and extract text using the GetText() method.

Extract Text from the Gear Type SmartArt Shape

The following sample code loads a sample Excel file containing a Gear Type SmartArt Shape and extracts text from its individual shapes. Refer to the console output below for results.

Sample Code

#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;
}

Console Output

Gear Type Shape Text: Nice
Gear Type Shape Text: Good
Gear Type Shape Text: Excellent