Estrai testo da SmartArt di tipo Gear con C++
Contents
[
Hide
]
Possibili Scenari di Utilizzo
Aspose.Cells for C++ può estrarre testo da SmartArt di tipo Gear. Per farlo, segui questi passi:
- Converti SmartArt Shape in forma di gruppo usando il metodo Shape::GetResultOfSmartArt().
- Recupera tutte le forme individuali che compongono il SmartArt Shape utilizzando il metodo GroupShape::GetGroupedShapes(). Itera attraverso ogni singola forma ed estrai il testo usando il metodo GetText().
Estrarre il testo dalla forma SmartArt di tipo ingranaggio
Il seguente esempio di codice carica un file Excel di esempio contenente una Forma SmartArt di Tipo Ingranaggio e ne estrae il testo dalle sue forme individuali. Consulta l’output della console sotto per i risultati.
Codice di Esempio
#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;
}
Output della console
Gear Type Shape Text: Nice
Gear Type Shape Text: Good
Gear Type Shape Text: Excellent