إنشاء جدول على شريحة باوربوينت
Contents
[
Hide
]
تُستخدم الجداول على نطاق واسع لعرض البيانات في شرائح العروض التقديمية. يوضح هذا المقال كيفية إنشاء جدول 15 × 15 بحجم خط 10 برمجيًا باستخدام VSTO 2008 ثم Aspose.Slides for Android via Java.
إنشاء الجداول
مثال VSTO 2008
تضيف الخطوات التالية جدولاً إلى شريحة Microsoft PowerPoint باستخدام VSTO:
- إنشاء عرض تقديمي.
- إضافة شريحة فارغة إلى العرض التقديمي.
- إضافة جدول 15 × 15 إلى الشريحة.
- إضافة نص لكل خلية من خلايا الجدول بحجم خط 10.
- حفظ العرض التقديمي على القرص.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Create a presentation | |
PowerPoint.Presentation pres = Globals.ThisAddIn.Application | |
.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoFalse); | |
//Add a blank slide | |
PowerPoint.Slide sld = pres.Slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutBlank); | |
//Add a 15 x 15 table | |
PowerPoint.Shape shp = sld.Shapes.AddTable(15, 15, 10, 10, pres.PageSetup.SlideWidth - 20, 300); | |
PowerPoint.Table tbl = shp.Table; | |
int i = -1; | |
int j = -1; | |
//Loop through all the rows | |
foreach (PowerPoint.Row row in tbl.Rows) | |
{ | |
i = i + 1; | |
j = -1; | |
//Loop through all the cells in the row | |
foreach (PowerPoint.Cell cell in row.Cells) | |
{ | |
j = j + 1; | |
//Get text frame of each cell | |
PowerPoint.TextFrame tf = cell.Shape.TextFrame; | |
//Add some text | |
tf.TextRange.Text = "T" + i.ToString() + j.ToString(); | |
//Set font size of the text as 10 | |
tf.TextRange.Paragraphs(0, tf.TextRange.Text.Length).Font.Size = 10; | |
} | |
} | |
//Save the presentation to disk | |
pres.SaveAs("d:\\tblVSTO.ppt", | |
PowerPoint.PpSaveAsFileType.ppSaveAsPresentation, | |
Microsoft.Office.Core.MsoTriState.msoFalse); |
مثال Aspose.Slides for Android via Java
تضيف الخطوات التالية جدولاً إلى شريحة Microsoft PowerPoint باستخدام Aspose.Slides:
- إنشاء عرض تقديمي.
- إضافة جدول 15 × 15 إلى الشريحة الأولى.
- إضافة نص لكل خلية من خلايا الجدول بحجم خط 10.
- كتابة العرض التقديمي على القرص.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Presentation pres = new Presentation(); | |
//Access first slide | |
ISlide sld = pres.getSlides().get_Item(0); | |
//Define columns with widths and rows with heights | |
double[] dblCols = { 50, 50, 50 }; | |
double[] dblRows = { 50, 30, 30, 30, 30 }; | |
//Add a table | |
ITable tbl = sld.getShapes().addTable(50, 50, dblCols,dblRows); | |
//Set border format for each cell | |
for (int i=0;i<tbl.getRows().size();i++) | |
{ | |
IRow row=tbl.getRows().get_Item(i); | |
for (int j=0;j<row.size();j++) | |
{ | |
ICell cell=row.get_Item(j); | |
//Get text frame of each cell | |
ITextFrame tf = cell.getTextFrame(); | |
//Add some text | |
tf.setText ("T" + cell.getFirstRowIndex() + cell.getFirstColumnIndex()); | |
//Set font size of 10 | |
tf.getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().setFontHeight(10); | |
tf.getParagraphs().get_Item(0).getParagraphFormat().getBullet().setType(BulletType.None); | |
} | |
} | |
//Write the presentation to the disk | |
pres.save("c:\\data\\outAsposeSlides.pptx",SaveFormat.Pptx); |