Syncfusion Feedback

Trusted by the world’s leading companies

Syncfusion Trusted Companies

Overview

Tables help arrange the Word document content in rows and columns. A row is a horizontal collection of cells and a column is a vertical collection of cells. Each cell can contain multiple paragraphs and additional tables. The Syncfusion .NET Word library (DocIO) allows users to create tables with just a few lines of code in C# without relying on Microsoft Word or interop dependencies.

Create a table in a Word document using C#

This example code shows how to create a table in a Word document using the Syncfusion .NET Word library with just a few lines C# code.

using Syncfusion.DocIO; 
using Syncfusion.DocIO.DLS;
//Create a new instance of a Word document  
using WordDocument document = new WordDocument();  
//Add a section and a paragraph to the document  
document.EnsureMinimal();  
//Add a new table to the Word document  
IWTable table = document.Sections[0].AddTable();  
//Specify the total number of rows and columns  
table.ResetCells(3, 2);  
//Access each table cell and append text  
table[0, 0].AddParagraph().AppendText("Item");  
table[0, 1].AddParagraph().AppendText("Price($)");  
table[1, 0].AddParagraph().AppendText("Apple");  
table[1, 1].AddParagraph().AppendText("50");  
table[2, 0].AddParagraph().AppendText("Orange");  
table[2, 1].AddParagraph().AppendText("30");  
//Save the Word document to FileStream  
using FileStream outputStream = new FileStream("Result.docx", FileMode.Create, FileAccess.Write);  
document.Save(outputStream, FormatType.Docx);

Key features of the table in Word documents

Table styles

Utilize built-in table styles or create custom styles to enhance the appearance of tables.

Conditional formatting

Enable or disable special formatting options such as first column, last column, banded rows, banded columns, header row, and last row after applying a table style, providing flexibility in table design.

Repetition of the header row

Set one or more rows to repeat as headers on each page in multi-page documents, ensuring consistency in table headers and improving document readability.

Break row across pages

Control whether or not the table row content can be split across multiple pages, ensuring that the row content fits appropriately.

Explore Table references

Check out our knowledge base articles to efficiently create and format tables in Word documents.

How to split a table without losing their format

Knowledge base

How to split a table without losing their format in a Word document using C#

How to find a table by title in a Word document and add a row

Knowledge base

How to find a table by title in a Word document and add a row

How to avoid table splitting across the pages

Knowledge base

How to avoid table splitting across the pages in Word document using C#

How to insert a row with the same formatting in a Word

Knowledge base

How to insert a row with the same formatting in a Word document

How to extract images from tables in a Word document

Knowledge base

How to extract images from tables in a Word document

How to change the font of table content in Word document

Knowledge base

How to change the font of table content in a Word document

Syncfusion .NET Word Library Resources

Explore these resources for comprehensive guides, knowledge base articles, insightful blogs, and ebooks.

Frequently Asked Questions

Yes, you can merge cells horizontally and vertically in a Word document using the .NET Word library (DocIO) in C#.

You have full control over the table’s appearance, including borders, padding, indents, and more, to customize the table’s look and feel in C#.

Adding more than 63 columns is not supported in Word documents via Microsoft Word, and an alert will appear when attempting to insert a table with more than 64 columns. DocIO follows the same limitation.

Absolutely. You can insert not just text, but also images, fields, and even other tables inside table cells programmatically.

Yes, you can format cell content with features like vertical alignment, text direction, and text wrapping using the .NET Word library (DocIO).

You can access it through the Syncfusion.DocIO.Net.Core NuGet package. Detailed code samples are available in the documentation, facilitating seamless integration.

Our Customers Love Us

Having an excellent set of tools and a great support team, Syncfusion® reduces customers’ development time.Here are some of their experiences.

Rated by users across the globe

Want to create, View, and edit Word documents in C# or VB.NET?

Start a free 30-day evaluation today!
DOWNLOAD FREE TRIAL

No credit card required.

Mobile Free Evaluation Section

Awards

Greatness—it’s one thing to say you have it, but it means more when others recognize it. Syncfusion® is proud to hold the following industry awards.

Scroll up icon