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, ITable

Inheritance

GraphicalObjectTable


Properties

PropertyTypeAccessDescription
RowsIRowCollectionReadCollection of table rows.
ColumnsIColumnCollectionReadCollection of table columns.
TableFormatITableFormatReadTable-level formatting (fill).
StylePresetTableStylePresetReadApplied table style preset.
FirstRowboolReadWhether the first row has special formatting.
FirstColboolReadWhether the first column has special formatting.
LastRowboolReadWhether the last row has special formatting.
LastColboolReadWhether the last column has special formatting.
HorizontalBandingboolReadWhether horizontal banding is enabled.
VerticalBandingboolReadWhether vertical banding is enabled.
RightToLeftboolReadWhether the table uses right-to-left layout.

Methods

MergeCells(ICell, ICell, bool)

Merge a range of cells.

ParameterTypeDescription
cell1ICellTop-left cell.
cell2ICellBottom-right cell.
allowSplittingboolAllow 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);

See Also