# Manage Rows and Columns in PowerPoint Tables in .NET

> Manage table rows and columns in PowerPoint with Aspose.Slides for .NET and speed up presentation editing and data updates.

Source: https://docs.aspose.com/slides/net/manage-rows-and-columns/
Updated: 2026-08-05


## **Introduction**

To allow you to manage a table's rows and columns in a PowerPoint presentation, Aspose.Slides provides the [Table](https://reference.aspose.com/slides/net/aspose.slides/table/) class, [ITable](https://reference.aspose.com/slides/net/aspose.slides/itable/) interface, and many other types. 

## **Set the First Row as a Header**

1. Create an instance of the [Presentation](https://reference.aspose.com/slides/net/aspose.slides/presentation) class and load the presentation. 
2. Get a slide's reference through its index. 
3. Create an [ITable](https://reference.aspose.com/slides/net/aspose.slides/itable/) object and set it to null.
4. Iterate through all [IShape](https://reference.aspose.com/slides/net/aspose.slides/ishape/) objects to find the relevant table. 
5. Set the table's first row as its header. 

This C# code shows you how to set a table's first row as its header:

```c#
using Aspose.Slides;
using Aspose.Slides.Export;

// Instantiates the Presentation class
Presentation pres = new Presentation("table.pptx");

// Accesses the first slide
ISlide sld = pres.Slides[0];

// Initializes the null TableEx
ITable tbl = null;

// Iterates through the shapes and sets a reference to the table
foreach (IShape shp in sld.Shapes)
{
    if (shp is ITable)
    {
        tbl = (ITable)shp;
    }
}

// Sets the first row of a table as its header
tbl.FirstRow = true;

// Saves the presentation to disk
pres.Save("First_row_header.pptx", SaveFormat.Pptx);
```


## **Clone a Table Row or Column**

1. Create an instance of the [Presentation](https://reference.aspose.com/slides/net/aspose.slides/presentation) class and load the presentation, 
2. Get a slide's reference through its index. 
3. Define an array of `columnWidth`.
4. Define an array of `rowHeight`.
5. Add an [ITable](https://reference.aspose.com/slides/net/aspose.slides/itable/) object to the slide through the [AddTable](https://reference.aspose.com/slides/net/aspose.slides/ishapecollection/addtable/) method.
6. Clone the table row.
7. Clone the table column.
8. Save the modified presentation.

This C# code shows you how to clone a PowerPoint table's row or column:

```c#
using Aspose.Slides;

 // Instantiates the Presentation class
using (Presentation presentation = new Presentation("Test.pptx"))
{
    // Accesses the first slide
    ISlide sld = presentation.Slides[0];

    // Defines columns with widths and rows with heights
    double[] dblCols = { 50, 50, 50 };
    double[] dblRows = { 50, 30, 30, 30, 30 };

    // Adds a table shape to the slide
    ITable table = sld.Shapes.AddTable(100, 50, dblCols, dblRows);

    // Adds some text to the row 1 cell 1
    table[0, 0].TextFrame.Text = "Row 1 Cell 1";

    // Adds some text to the row 1 cell 2
    table[1, 0].TextFrame.Text = "Row 1 Cell 2";

    // Clones Row 1 at the end of table
    table.Rows.AddClone(table.Rows[0], false);

    // Adds some text to the row 2 cell 1
    table[0, 1].TextFrame.Text = "Row 2 Cell 1";

    // Adds some text to the row 2 cell 2
    table[1, 1].TextFrame.Text = "Row 2 Cell 2";

    // Clones Row 2 as the 4th row of table
    table.Rows.InsertClone(3,table.Rows[1], false);

    // Clones first column at the end
    table.Columns.AddClone(table.Columns[0], false);

    // Clones 2nd column at 4th column index
    table.Columns.InsertClone(3,table.Columns[1], false);
    
    // Saves the presentation to disk 
    presentation.Save("table_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
}
```

## **Remove a Row or Column from a Table**

1. Create an instance of the [Presentation](https://reference.aspose.com/slides/net/aspose.slides/presentation) class and load the presentation, 
2. Get a slide's reference through its index. 
3. Define an array of `columnWidth`.
4. Define an array of `rowHeight`.
5. Add an [ITable](https://reference.aspose.com/slides/net/aspose.slides/itable/) object to the slide through the [AddTable](https://reference.aspose.com/slides/net/aspose.slides/ishapecollection/addtable/) method.
6. Remove the table row.
7. Remove the table column.
8. Save the modified presentation. 

This C# code shows you how to remove a row or column from a table:

```c#
using Aspose.Slides;

Presentation pres = new Presentation();

ISlide slide = pres.Slides[0];
double[] colWidth = { 100, 50, 30 };
double[] rowHeight = { 30, 50, 30 };

ITable table = slide.Shapes.AddTable(100, 100, colWidth, rowHeight);
table.Rows.RemoveAt(1, false);
table.Columns.RemoveAt(1, false);
pres.Save("TestTable_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
```

## **Set Text Formatting on the Table Row Level**

1. Create an instance of the [Presentation](https://reference.aspose.com/slides/net/aspose.slides/presentation) class and load the presentation, 
2. Get a slide's reference through its index. 
3. Access the relevant [ITable](https://reference.aspose.com/slides/net/aspose.slides/itable/) object from the slide. 
4. Set the first-row cells' [FontHeight](https://reference.aspose.com/slides/net/aspose.slides/baseportionformat/fontheight/). 
5. Set the first-row cells' [Alignment](https://reference.aspose.com/slides/net/aspose.slides/iparagraphformat/alignment/) and [MarginRight](https://reference.aspose.com/slides/net/aspose.slides/iparagraphformat/marginright/). 
6. Set the second-row cells' [TextVerticalType](https://reference.aspose.com/slides/net/aspose.slides/textframeformat/textverticaltype/).
7. Save the modified presentation.

This C# code demonstrates the operation.

```c#
using Aspose.Slides;

// Creates an instance of the Presentation class
Presentation presentation = new Presentation();
           
ISlide slide = presentation.Slides[0];

ITable someTable = presentation.Slides[0].Shapes[0] as ITable; // Let's assume that the first shape on the first slide is a table

// Sets first row cells' font height
PortionFormat portionFormat = new PortionFormat();
portionFormat.FontHeight = 25;
someTable.Rows[0].SetTextFormat(portionFormat);

// Sets the first row cells' text alignment and right margin
ParagraphFormat paragraphFormat = new ParagraphFormat();
paragraphFormat.Alignment = TextAlignment.Right;
paragraphFormat.MarginRight = 20;
someTable.Rows[0].SetTextFormat(paragraphFormat);

// Sets the second row cells' text vertical type
TextFrameFormat textFrameFormat = new TextFrameFormat();
textFrameFormat.TextVerticalType = TextVerticalType.Vertical;
someTable.Rows[1].SetTextFormat(textFrameFormat);

// Saves the presentation to disk
presentation.Save("result.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
```

## **Set Text Formatting on the Table Column Level**

1. Create an instance of the [Presentation](https://reference.aspose.com/slides/net/aspose.slides/presentation) class and load the presentation, 
2. Get a slide's reference through its index. 
3. Access the relevant [ITable](https://reference.aspose.com/slides/net/aspose.slides/itable/) object from the slide. 
4. Set the first-column cells' [FontHeight](https://reference.aspose.com/slides/net/aspose.slides/baseportionformat/fontheight/). 
5. Set the first-column cells' [Alignment](https://reference.aspose.com/slides/net/aspose.slides/iparagraphformat/alignment/) and [MarginRight](https://reference.aspose.com/slides/net/aspose.slides/iparagraphformat/marginright/). 
6. Set the second-column cells' [TextVerticalType](https://reference.aspose.com/slides/net/aspose.slides/textframeformat/textverticaltype/).
7. Save the modified presentation. 

This C# code demonstrates the operation: 

```c#
using Aspose.Slides;

// Creates an instance of the Presentation class
Presentation pres = new Presentation();
           
ISlide slide = pres.Slides[0];

ITable someTable = pres.Slides[0].Shapes[0] as ITable; // Let's assume that the first shape on the first slide is a table

// Sets the first column cells' font height
PortionFormat portionFormat = new PortionFormat();
portionFormat.FontHeight = 25;
someTable.Columns[0].SetTextFormat(portionFormat);

// Sets the first column cells' text alignment and right margin in one call
ParagraphFormat paragraphFormat = new ParagraphFormat();
paragraphFormat.Alignment = TextAlignment.Right;
paragraphFormat.MarginRight = 20;
someTable.Columns[0].SetTextFormat(paragraphFormat);

// Sets the second column cells' text vertical type
TextFrameFormat textFrameFormat = new TextFrameFormat();
textFrameFormat.TextVerticalType = TextVerticalType.Vertical;
someTable.Columns[1].SetTextFormat(textFrameFormat);

// Saves the presentation to disk
pres.Save("result.pptx", Aspose.Slides.Export.SaveFormat.Pptx);

```

## **Get Table Style Properties**

Aspose.Slides allows you to retrieve the style properties for a table so that you can use those details for another table or somewhere else. This C# code shows you how to get the style properties from a table preset style: 

```c#
using Aspose.Slides;
using Aspose.Slides.Export;

using (Presentation pres = new Presentation())
{
    ITable table = pres.Slides[0].Shapes.AddTable(10, 10, new double[] { 100, 150 }, new double[] { 5, 5, 5 });
    table.StylePreset = TableStylePreset.DarkStyle1; // change the default style preset theme 

    // Gets the style preset applied to the table, so it can be reused elsewhere
    TableStylePreset stylePreset = table.StylePreset;
    Console.WriteLine(stylePreset); // DarkStyle1

    pres.Save("table.pptx", SaveFormat.Pptx);
}
```

## **FAQ**

### Can I apply PowerPoint themes/styles to a table that’s already created?

Yes. The table inherits the slide/layout/master theme, and you can still override fills, borders, and text colors on top of that theme.

### Can I sort table rows like in Excel?

No, Aspose.Slides tables don’t have built-in sorting or filters. Sort your data in memory first, then repopulate the table rows in that order.

### Can I have banded (striped) columns while keeping custom colors on specific cells?

Yes. Turn on banded columns, then override specific cells with local formatting; cell-level formatting takes precedence over the table style.

