public static void Run()
{
// For complete examples and data files, please go to https:// Github.com/aspose-slides/Aspose.Slides-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Tables();
// Instantiate presentationentation class that representationents PPTX file
using (Presentation presentation = new Presentation())
{
// Access first slide
ISlide sld = presentation.Slides[0];
// Define columns with widths and rows with heights
double[] dblCols = { 50, 50, 50 };
double[] dblRows = { 50, 30, 30, 30, 30 };
// Add table shape to slide
ITable table = sld.Shapes.AddTable(100, 50, dblCols, dblRows);
// Set border format for each cell
foreach (IRow row in table.Rows)
foreach (ICell cell in row)
{
cell.BorderTop.FillFormat.FillType = FillType.Solid;
cell.BorderTop.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderTop.Width = 5;
cell.BorderBottom.FillFormat.FillType = FillType.Solid;
cell.BorderBottom.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderBottom.Width = 5;
cell.BorderLeft.FillFormat.FillType = FillType.Solid;
cell.BorderLeft.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderLeft.Width = 5;
cell.BorderRight.FillFormat.FillType = FillType.Solid;
cell.BorderRight.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderRight.Width = 5;
}
// Merge cells 1 & 2 of row 1
table.MergeCells(table[0, 0], table[1, 0], false);
// Add text to the merged cell
table[0, 0].TextFrame.Text = "Merged Cells";
// Write PPTX to Disk
presentation.Save(dataDir + "table_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
}
}
}