Table — Aspose.Slides FOSS for .NET API Reference
The Table class represents a table shape on a slide. It provides access to rows, columns, cells, merge operations, and style presets.
Package: Aspose.Slides.Foss (net9.0)
using Aspose.Slides.Foss;public class Table : GraphicalObject, ITableInheritance
GraphicalObject → Table
Properties
| Property | Type | Access | Description |
|---|---|---|---|
Rows | IRowCollection | Read | Collection of table rows. |
Columns | IColumnCollection | Read | Collection of table columns. |
TableFormat | ITableFormat | Read | Table-level formatting (fill). |
StylePreset | TableStylePreset | Read | Applied table style preset. |
FirstRow | bool | Read | Whether the first row has special formatting. |
FirstCol | bool | Read | Whether the first column has special formatting. |
LastRow | bool | Read | Whether the last row has special formatting. |
LastCol | bool | Read | Whether the last column has special formatting. |
HorizontalBanding | bool | Read | Whether horizontal banding is enabled. |
VerticalBanding | bool | Read | Whether vertical banding is enabled. |
RightToLeft | bool | Read | Whether the table uses right-to-left layout. |
Methods
MergeCells(ICell, ICell, bool)
Merge a range of cells.
| Parameter | Type | Description |
|---|---|---|
cell1 | ICell | Top-left cell. |
cell2 | ICell | Bottom-right cell. |
allowSplitting | bool | Allow splitting already-merged cells. |
SetTextFormat(IBasePortionFormat)
Apply portion formatting to all cells in the table.
SetTextFormat(IParagraphFormat)
Apply paragraph formatting to all cells.
SetTextFormat(ITextFrameFormat)
Apply text frame formatting to all cells.
Usage Examples
Create a Table
using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Export;
using var prs = new Presentation();
var slide = prs.Slides[0];
double[] colWidths = { 120, 120, 120 };
double[] rowHeights = { 40, 40, 40 };
var table = slide.Shapes.AddTable(50, 50, colWidths, rowHeights);
// Set cell text
table.Rows[0][0].TextFrame.Text = "Name";
table.Rows[0][1].TextFrame.Text = "Role";
table.Rows[0][2].TextFrame.Text = "Status";
table.Rows[1][0].TextFrame.Text = "Alice";
table.Rows[1][1].TextFrame.Text = "Engineer";
table.Rows[1][2].TextFrame.Text = "Active";
prs.Save("table.pptx", SaveFormat.Pptx);Merge Cells
using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Export;
using var prs = new Presentation();
double[] cols = { 100, 100, 100 };
double[] rows = { 40, 40 };
var table = prs.Slides[0].Shapes.AddTable(50, 50, cols, rows);
// Merge the entire first row into one cell
table.MergeCells(table.Rows[0][0], table.Rows[0][2], false);
table.Rows[0][0].TextFrame.Text = "Header spanning all columns";
prs.Save("merged.pptx", SaveFormat.Pptx);