يرشدك هذا البرنامج التعليمي القصير إلى ** كيفية إدراج جدول في شريحة باستخدام Java **. يشارك التفاصيل الضرورية لتعيين IDE لكتابة التطبيق والخطوات التفصيلية لأداء هذه المهمة. في النهاية ، ستحصل على نموذج تعليمة برمجية قابلة للتشغيل توضح ** كيفية إنشاء جدول في PowerPoint باستخدام Java ** وحفظ العرض التقديمي الناتج على القرص كـ PPTX أو PPT أو في أي شيء آخر تنسيق مدعوم دون تثبيت MS PowerPoint أو أي أداة أخرى تابعة لجهة خارجية.
خطوات إضافة جدول في PowerPoint باستخدام Java
- قم بتعيين IDE لاستخدام Aspose.Slides لإدراج جدول
- قم بإنشاء عرض تقديمي جديد باستخدام فئة Presentation والوصول إلى الشريحة الأولى
- أضف جدولًا جديدًا في الشريحة المحددة باستخدام طريقة addTable() وتوفير موضع النص وارتفاع الخلايا وعرضها
- كرر خلال جميع الصفوف وقم بتعيين النص مع إعدادات الخط
- احفظ العرض التقديمي على القرص الذي يحتوي على جدول فيه
توضح الخطوات المذكورة أعلاه * كيفية إنشاء جداول في PowerPoint باستخدام Java *. يتم تحديد جميع الفئات والطرق الضرورية تلك المطلوبة لإنجاز المهمة. العملية بسيطة حيث يتم إضافة جدول إلى شريحة ثم تمتلئ خلاياه ببعض النص النموذجي.
رمز لإنشاء جدول في PowerPoint باستخدام Java
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package testslides; | |
import com.aspose.slides.BulletType; | |
import com.aspose.slides.ICell; | |
import com.aspose.slides.IRow; | |
import com.aspose.slides.ISlide; | |
import com.aspose.slides.ITable; | |
import com.aspose.slides.ITextFrame; | |
import com.aspose.slides.License; | |
import com.aspose.slides.Presentation; | |
public class AddTable { | |
public static void main(String[] args) throws Exception {//handle exception during adding any tablle | |
String path = "/Users/mudassirkhan/Documents/KnowledgeBase/TestData/"; | |
// Load the product license to create a table | |
License slidesTablelic = new License(); | |
slidesTablelic.setLicense(path + "Conholdate.Total.Product.Family.lic"); | |
// Create a new presentation | |
Presentation presentationForTable = new Presentation(); | |
// Access the first slide in the presentation | |
ISlide slide = presentationForTable.getSlides().get_Item(0); | |
// Define the arrays containing column widths and row heights | |
double[] dColumnsWidths = { 55, 55, 55 }; | |
double[] dRowsHeights = { 55, 36, 36, 36, 36 }; | |
// Add a new table with desired rows and columns | |
ITable newTable = slide.getShapes().addTable(60, 60, dColumnsWidths, dRowsHeights); | |
// Traverse through all the rows | |
for (IRow tableRow : newTable.getRows()) | |
{ | |
// Traverse through all the cells in the current row | |
for (ICell tableCell : tableRow) | |
{ | |
// Access the respective text frame of the cell | |
ITextFrame txtFormat = tableCell.getTextFrame(); | |
// Add some text to the cell | |
int iFirstRowIndex = tableCell.getFirstRowIndex(); | |
int iFirstColumnIndex = tableCell.getFirstColumnIndex(); | |
txtFormat.setText( "Text " + iFirstRowIndex + " " + iFirstColumnIndex); | |
// Set the font related property for the newly added text | |
txtFormat.getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().setFontHeight(10); | |
txtFormat.getParagraphs().get_Item(0).getParagraphFormat().getBullet().setType(BulletType.None); | |
} | |
} | |
// Save the presentation with table | |
presentationForTable.save("PresentationTable.pptx", com.aspose.slides.SaveFormat.Pptx); | |
System.out.println("Done"); | |
} | |
} |
يوضح هذا الرمز * كيفية إنشاء جدول في PowerPoint باستخدام Java *. تُستخدم فئات الواجهة المتعددة لاستخدام ميزات مختلفة ، على سبيل المثال ، يتم استخدام ISlide للوصول إلى الشريحة ، ويتم استخدام فئة ITable للعمل مع الجداول ، ويتم استخدام فئتي IRow و ICell للعمل مع الخلايا الفردية. فئة ITextFrame هي الواجهة الرئيسية المستخدمة لتعيين النص في خلية وتعيين تنسيق الخلايا.
لقد علمنا هذا البرنامج التعليمي * كيفية عمل جدول في عرض PowerPoint التقديمي باستخدام Java *. إذا كنت تريد تعلم عملية إنشاء HTML من عرض تقديمي ، فراجع المقالة على كيفية إنشاء شرائح PowerPoint بتنسيق HTML باستخدام Java.