How to Create a Table in PowerPoint using C#

This article guides on how to create a table in PowerPoint using C#. It provides all the details to establish the environment, a step-by-step process to create and fill a table, and a runnable sample code that demonstrates how to insert a table in a slide using C#. You will also learn to format the text in the table and save the resultant presentation on the disk in PPT, PPTX, or any other format supported by MS PowerPoint.

Steps to Create a Table in PowerPoint using C#

  1. Establish the environment to add Aspose.Slides for .NET to add a table
  2. Create a new presentation using the Presentation class and access its first slide
  3. Add a table in the slide having the defined heights for rows and columns using the AddTable() method
  4. Iterate through each row and cell of the newly added table
  5. Set some text in each cell and sets its font
  6. Save the presentation in the PPT format

These steps explain how to make table in PowerPoint using C#. First, you may create a presentation and get access to the first slide in it that contains a collection of shapes by default. In the next steps create a table by providing the X and Y coordinates for the top left position of the text in a cell along with the integers array describing the rows’ height and columns’ width. In the final steps, create an ITextFrame class object and set the text paragraph formatting as per your requirements before saving the output file.

Code to Add Table in PowerPoint using C#

This code assists on how to create tables in PowerPoint using C# where the Aspose.Slides.ITable object is used to create a table having a collection of rows and columns by default for inserting data into them. The ITextFrame class object sets text, font height, and bullet type. You may set other properties like highlight text, add or remove a field, set fill format, and set highlight color to name a few.

This tutorial has described how will you insert a table in a presentation using C#. If you want to learn the process to secure a PowerPoint presentation refer to the article on how to secure PowerPoint presentation in C#.

 English