استخراج النص من شكل SmartArt نوع الحركة
سيناريوهات الاستخدام المحتملة
يمكن لـ Aspose.Cells استخراج النص من شكل Smart Art Shape. من أجل القيام بذلك ، يجب عليك أولاً تحويل Smart Art Shape إلى مجموعة Shape باستخدام الطريقة Shape.GetResultOfSmartArt(). بعد ذلك يجب عليك الحصول على مصفوفة من جميع الأشكال الفردية التي تشكل مجموعة الشكل باستخدام الطريقة GroupShape.GetGroupedShapes(). وأخيرًا ، يمكنك تكرار جميع الأشكال الفردية واحدًا تلو الآخر في حلقة واحدة واستخراج نصوصها باستخدام الخاصية Shape.Text.
استخراج النص من شكل SmartArt نوع الحركة
يحمل الكود العيني التالي ملف Excel العيني الذي يحتوي على شكل Smart Art Shape من نوع العتاد. ثم يستخرج النص من الأشكال الفردية له كما هو موضح أعلاه. يرجى الاطلاع على مخرجات الوحدة المعطاة أدناه كمرجع.
الكود المثالي
// 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