Table
Contents
[
Hide
]
Examples for adding tables, accessing them, removing them, and merging cells using Aspose.Slides for .NET.
Add a Table
Create a simple table with two rows and two columns.
static void AddTable()
{
using var presentation = new Presentation();
var slide = presentation.Slides[0];
double[] widths = { 80, 80 };
double[] heights = { 30, 30 };
var table = slide.Shapes.AddTable(50, 50, widths, heights);
}
Access a Table
Retrieve the first table shape on the slide.
static void AccessTable()
{
using var presentation = new Presentation();
var slide = presentation.Slides[0];
double[] widths = { 80, 80 };
double[] heights = { 30, 30 };
var table = slide.Shapes.AddTable(50, 50, widths, heights);
// Access first table on slide.
var firstTable = slide.Shapes.OfType<ITable>().First();
}
Remove a Table
Delete a table from a slide.
static void RemoveTable()
{
using var presentation = new Presentation();
var slide = presentation.Slides[0];
double[] widths = { 80, 80 };
double[] heights = { 30, 30 };
var table = slide.Shapes.AddTable(50, 50, widths, heights);
slide.Shapes.Remove(table);
}
Merge Table Cells
Merge adjacent cells of a table into a single cell.
static void MergeTableCells()
{
using var presentation = new Presentation();
var slide = presentation.Slides[0];
double[] widths = { 80, 80 };
double[] heights = { 30, 30 };
var table = slide.Shapes.AddTable(50, 50, widths, heights);
table.MergeCells(table[0, 0], table[1, 1], false);
}