استخراج النص من شكل فن ذكي من نوع الترس باستخدام C++

سيناريوهات الاستخدام المحتملة

يمكن لـ Aspose.Cells for C++ استخراج النص من شكل فن ذكي من نوع الترس. لتحقيق ذلك، اتبع الخطوات التالية:

  1. تحويل شكل الفن الذكي إلى شكل مجموعة باستخدام طريقة Shape::GetResultOfSmartArt().
  2. استرجاع جميع الأشكال الفردية التي تشكل شكل المجموعة باستخدام طريقة GroupShape::GetGroupedShapes().
  3. التكرار عبر كل شكل فردي واستخراج النص باستخدام طريقة GetText().

استخراج النص من شكل SmartArt نوع الحركة

الشيفرة النموذجية التالية تقوم بتحميل ملف إكسل نموذج يحتوي على شكل فن ذكي من نوع الترس وتستخرج النص من أشكاله الفردية. يرجى مراجعة مخرجات وحدة التحكم أدناه للنتائج.

الكود المثالي

#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