How to Create Table in Word Document using C#

This tutorial lists two different ways to create table in Word document using C#. We will first create table in Word using C# with the help of an Aspose DocumentBuilder and later create Word table using C# directly in Word document object model (DOM).

Steps to Create Table in Word Document using C#

  1. Reference the Aspose.Words for .NET package from NuGet in solution
  2. Import Aspose.Words and Aspose.Words.Tables namespaces
  3. Create DocumentBuilder or Table class instance
  4. Use InsertCell or Table.Rows.Cells.Add method to add cells in table row
  5. Use DocumentBuilder.Write or Cell.AppendChild method to insert paragraph text
  6. Create multiple rows in table and finish table creation in Word document
  7. Save as Word document with table to DOCX format on disk

The following Aspose DocumentBuilder code example can be used in .NET application for C# Word table creation.

Code to Create Table in Word Document using C#

Essentially, this create table Word C# app enables you to insert a table in Word document. It first adds two cells in the first table row and later writes text content in first cell and then add image to Word C# last cell.

Code to Create Word Table using C# (DOM Classes)

The above Aspose Word create table C# code example just presents an alternate approach for adding a table element in Word document object model using Table, Row, Cell and Paragraph classes.