كيفية إنشاء جدول في PowerPoint باستخدام Python

ترشد هذه المقالة البسيطة ** كيفية إنشاء جدول في PowerPoint باستخدام Python **. يغطي جميع المعلومات لإعداد البيئة ، وإجراء خطوة بخطوة لإدخال البيانات وتعبئتها داخل جدول ، ونموذج تعليمة برمجية يوضح ** كيفية إدراج جدول في شريحة باستخدام Python **. كما تتناول أيضًا كيفية تنسيق النص داخل خلية الجدول وحفظ العرض التقديمي على القرص إما بتنسيق PPT أو PPTX.

خطوات إنشاء جدول في PowerPoint باستخدام Python

  1. قم بتكوين بيئة لاستخدام Aspose.Slides لـ Python عبر .NET في تطبيقك لإضافة جدول
  2. قم بإنشاء عرض تقديمي جديد فارغ باستخدام فئة Presentation والوصول إلى الشريحة الافتراضية الأولى
  3. أدخل جدولاً في الشريحة يحتوي على عرض الأعمدة المحدد وارتفاع الصفوف باستخدام طريقة add_table()
  4. اجتياز كل صف والخلية الخاصة به داخل الجدول المضاف حديثًا
  5. عيّن نموذج النص مع الخصائص المتعلقة بالخط داخل كل خلية
  6. احفظ العرض التقديمي مع جدول بتنسيق PPTX على القرص

توضح الخطوات المذكورة أعلاه * كيفية إنشاء جدول في PowerPoint باستخدام Python * حيث في الخطوة الأولى ، سننشئ عرضًا تقديميًا افتراضيًا ونصل إلى الشريحة الأولى. في الخطوات اللاحقة ، سنضيف جدولًا عن طريق توفير إحداثيات الموقع للجدول جنبًا إلى جنب مع عرض الأعمدة وارتفاع الصفوف. في الخطوات الأخيرة ، سوف نكرر كل خلية داخل الجدول لتعيين النص جنبًا إلى جنب مع التنسيق الخاص به قبل حفظ العرض التقديمي الناتج على القرص.

كود لإضافة جدول في PowerPoint باستخدام Python

import aspose.pydrawing as draw
import aspose.slides as slides
# Path to the license file directory
filepath = "Y://Documents//KnowledgeBase//TestData//"
# Load the license in your application for creating the table
slidesTableLicense = slides.License()
slidesTableLicense.set_license(filepath + "Conholdate.Total.Product.Family.lic")
# Instantiate the Presentation object to add the table
with slides.Presentation() as presentationTable:
# Access the first default slide
slide = presentationTable.slides[0]
# Define the columns widths and rows heights
dblColsWidth = [50, 50, 50]
dblRowsHeight = [50, 30, 30, 30, 30]
# Insert the table shape to slide
table = slide.shapes.add_table(100, 50, dblColsWidth, dblRowsHeight)
# Set the border format for each cell
for rowIndex in range(len(table.rows)):
for cellIndex in range(len(table.rows[rowIndex])):
table.rows[rowIndex][cellIndex].cell_format.border_top.fill_format.fill_type = slides.FillType.SOLID
table.rows[rowIndex][cellIndex].cell_format.border_top.fill_format.solid_fill_color.color = draw.Color.red
table.rows[rowIndex][cellIndex].cell_format.border_top.width = 5
table.rows[rowIndex][cellIndex].cell_format.border_bottom.fill_format.fill_type = slides.FillType.SOLID
table.rows[rowIndex][cellIndex].cell_format.border_bottom.fill_format.solid_fill_color.color= draw.Color.red
table.rows[rowIndex][cellIndex].cell_format.border_bottom.width =5
table.rows[rowIndex][cellIndex].cell_format.border_left.fill_format.fill_type = slides.FillType.SOLID
table.rows[rowIndex][cellIndex].cell_format.border_left.fill_format.solid_fill_color.color =draw.Color.red
table.rows[rowIndex][cellIndex].cell_format.border_left.width = 5
table.rows[rowIndex][cellIndex].cell_format.border_right.fill_format.fill_type = slides.FillType.SOLID
table.rows[rowIndex][cellIndex].cell_format.border_right.fill_format.solid_fill_col or.color = draw.Color.red
table.rows[rowIndex][cellIndex].cell_format.border_right.width = 5
# Merge the cells 1 and 2 of row 1
table.merge_cells(table.rows[0][0], table.rows[1][1], False)
# Add the text inside the merged cell
table.rows[0][0].text_frame.text = "Merged Table Cells"
presentationTable.save(filepath + "NewPresentationWithTable.pptx", slides.export.SaveFormat.PPTX)
print("Done")

يستلزم هذا المثال * كيفية إنشاء جداول في PowerPoint باستخدام Python * حيث يتم استخدام مثيل فئة Table لإدراج جدول يحتوي على مجموعة من الصفوف والأعمدة. يعيّن كائن فئة TextFrame النص وارتفاع الخط ونوع التعداد النقطي لنص الفقرة. يمكنك أيضًا استخدام الخصائص الأخرى ذات الصلة مثل تمييز النص وتعيين تنسيق التعبئة وإضافة حقل أو إزالته وتعيين لون التمييز على سبيل المثال لا الحصر.

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

 عربي