Create Excel Table in Just 3 Steps Using C#
Tags: fileformats, csharp, excel, dotnet
Published: 2024-04-26 09:28:03

---
title: Create Excel Table in Just 3 Steps Using C#
published: true
date: 2024-04-25 13:15:35 UTC
tags: fileformats, csharp, excel, dotnet
canonical_url: https://www.syncfusion.com/blogs/post/create-excel-table-in-3-steps-csharp
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nar1s67e8unq8ctg4ukh.png
---

**TL;DR:** Syncfusion’s Excel Library provides a full-fledged object model that facilitates accessing and manipulating Excel documents without Microsoft Office or interop dependencies. Let’s learn to create Excel tables with this comprehensive tool in just three simple steps.

The [Syncfusion Excel Library](https://www.syncfusion.com/document-processing/excel-framework/net "Syncfusion Excel Library"), also known as Essential XlsIO, is a robust tool that facilitates the smooth creation, reading, and editing of Excel documents using C#. It supports the creation of Excel documents from scratch, modification of existing Excel documents, data import and export, Excel formulas, conditional formats, data validations, charts, sparklines, tables, pivot tables, pivot charts, template markers, and much more.

This blog will explore the steps to create an Excel table using the Syncfusion Excel Library and C#.

**Note:** Please refer to the [.NET Excel Library’s getting started documentation](https://help.syncfusion.com/file-formats/xlsio/create-excel-file-csharp-vbnet "Create Excel File in C# and VB.NET") before proceeding.

## Steps to create a table in Excel

Follow these steps to create a table in an Excel document using C#:

1. First, create a [.NET Core Console application](https://docs.microsoft.com/en-us/dotnet/core/tutorials/with-visual-studio "Create a .NET console application using Visual Studio") in [Visual Studio](https://visualstudio.microsoft.com/vs/ "Visual Studio"), as shown in the following image.  
 ![Create a .NET Core Console application](https://www.syncfusion.com/blogs/wp-content/uploads/2024/04/Create-a-.NET-Core-Console-application-1.png)
2. Then, install the latest [Syncfusion.XlsIO.NET.Core](https://www.nuget.org/packages/Syncfusion.XlsIO.Net.Core "Syncfusion.XlsIO.Net.Core NuGet package") NuGet package to your app. ![Install Syncfusion.XlsIO.Net.Core NuGet](https://www.syncfusion.com/blogs/wp-content/uploads/2024/04/Install-Syncfusion.XlsIO_.Net_.Core-NuGet.png)
3. Now, add the following code to create a table in the existing Excel document.
```csharp
using Syncfusion.XlsIO;

namespace ExcelTable
{
    class Program
    {
        public static void Main()
        {
            Program program = new Program();
            program.CreateTable();
        }

        /// <summary>
        /// Creates a table in the existing Excel document.
        /// </summary>
        public void CreateTable()
        {
            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                IApplication application = excelEngine.Excel;
                application.DefaultVersion = ExcelVersion.Xlsx;
                FileStream fileStream = new FileStream("../../../Data/SalesReport.xlsx", FileMode.Open, FileAccess.Read);
                IWorkbook workbook = application.Workbooks.Open(fileStream, ExcelOpenType.Automatic);
                IWorksheet worksheet = workbook.Worksheets[0];

                AddExcelTable("Table1", worksheet.UsedRange);
                
                string fileName = "../../../Output/Table.xlsx";

                //Saving the workbook as stream.
                FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite);
                workbook.SaveAs(stream);
                stream.Dispose();
            }
        }

        /// <summary>
        /// Adds a table to the worksheet with the given name and range.
        /// </summary>
        /// <param name="tableName">Table name</param>
        /// <param name="tableRange">Table range</param>
        public void AddExcelTable(string tableName, IRange tableRange)
        {
            IWorksheet worksheet = tableRange.Worksheet;

            //Create a table with the data in a given range.
            IListObject table = worksheet.ListObjects.Create(tableName, tableRange);

            //Set the table style.
            table.BuiltInTableStyle = TableBuiltInStyles.TableStyleMedium14;
        }
    }
}
```

Refer to the following images.

<figure>

  <img src="https://www.syncfusion.com/blogs/wp-content/uploads/2024/04/Input-Excel-document.gif" alt="Input Excel document" style="width:100%">

  <figcaption>Input Excel document</figcaption>

</figure>

<figure>

  <img src="https://www.syncfusion.com/blogs/wp-content/uploads/2024/04/Creating-a-table-in-an-Excel-document-using-Syncfusion-.NET-Excel-Library-and-C.gif" alt="Creating a table in an Excel document using Syncfusion .NET Excel Library and C#" style="width:100%">

  <figcaption>Creating a table in an Excel document using Syncfusion .NET Excel Library and C#</figcaption>

</figure>

**Note:** For more details, refer to [working with Excel table in C# documentation](https://help.syncfusion.com/file-formats/xlsio/working-with-excel-tables "Working with Excel Tables").

## GitHub reference

You can also download the [example for creating a table in Excel using C# on GitHub](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Create%20and%20Edit%20Table/ExcelTable "Creating a table in Excel using C# GitHub demo").

## Conclusion

Thanks for reading! In this blog, we explored how to create tables in Excel documents using C# and [Syncfusion Excel Library](https://www.syncfusion.com/excel-framework/net "Syncfusion Excel Library")**(XlsIO)**. The Excel Library also allows you to export Excel data to [images](https://help.syncfusion.com/file-formats/xlsio/worksheet-to-image-conversion "Worksheet to Image conversion in Excel Library"), [data tables](https://help.syncfusion.com/file-formats/xlsio/working-with-data#exporting-from-worksheet-to-data-table "Exporting from Worksheet to Data Table"), [CSV](https://www.syncfusion.com/kb/9092/convert-excel-file-to-csv-in-c-vb-net "KB: Convert Excel file to CSV in C#, VB.NET"), [TSV](https://www.syncfusion.com/kb/8556/does-xlsio-support-tsv-files "KB: Does XlsIO support TSV files?"), [HTML](https://help.syncfusion.com/file-formats/xlsio/working-with-excel-worksheet?_ga=2.19528508.561950334.1598519523-255771547.1598519523#save-worksheet-as-html "Save Worksheet as HTML"), [collections of objects](https://help.syncfusion.com/file-formats/xlsio/working-with-data#exporting-from-worksheet-to-clr-objects "Working with Excel Data"), [ODS](https://help.syncfusion.com/file-formats/xlsio/excel-to-ods-conversion "Excel to ODS Conversion"), [JSON](https://help.syncfusion.com/file-formats/xlsio/excel-to-json-conversion "Excel to JSON Conversion"), and other file formats.

Take a moment to peruse the [import data](https://help.syncfusion.com/file-formats/xlsio/working-with-data#importing-data-to-worksheets "Importing Data to Worksheets") documentation, where you’ll discover additional importing options and features such as [data tables](https://help.syncfusion.com/file-formats/xlsio/working-with-data#import-data-from-datatable "Import Data from DataTable"), [collection objects](https://help.syncfusion.com/file-formats/xlsio/working-with-data#import-data-from-collection-objects "Import Data from Collection Objects"), [grid view](https://help.syncfusion.com/file-formats/xlsio/working-with-data#import-data-from-dataview "Import Data from DataView"), [data columns](https://help.syncfusion.com/file-formats/xlsio/working-with-data#import-data-from-datacolumn "Importing Data from DataColumn"), and [HTML](https://help.syncfusion.com/file-formats/xlsio/working-with-data#importing-html-table-to-excel-worksheet "Importing HTML Table to Excel Worksheet"), all accompanied by code samples. 

Feel free to try out this versatile .NET Excel Library and share your feedback in the comments section of this blog post! 

For existing customers, the new version of Essential Studio is available for download from the [License and Downloads](https://www.syncfusion.com/account/downloads "Essential Studio License and Downloads page") page. If you are not yet a Syncfusion customer, you can try our 30-day [free trial](https://www.syncfusion.com/downloads "Get the free 30-day evaluation of Essential Studio products") to check out our available features.

For questions, you can contact us through our [support forum](https://www.syncfusion.com/forums "Syncfusion Support Forum"), [support portal](https://support.syncfusion.com/ "Syncfusion Support Portal"), or [feedback portal](https://www.syncfusion.com/feedback/ "Syncfusion Feedback Portal"). We are always happy to assist you!

## Related blogs

- [Print Excel Documents in Just 4 Steps Using C#](https://www.syncfusion.com/blogs/post/print-excel-in-csharp.aspx "Blog: Print Excel Documents in Just 4 Steps Using C#")
- [Converting XLS to XLSX Format in Just 3 Steps Using C#](https://www.syncfusion.com/blogs/post/convert-xls-to-xlsx-csharp.aspx "Blog: Converting XLS to XLSX Format in Just 3 Steps Using C#")
- [Merge Multiple Excel Files into One in Just 3 Steps Using C#](https://www.syncfusion.com/blogs/post/merge-multiple-excel-csharp.aspx "Blog: Merge Multiple Excel Files into One in Just 3 Steps Using C#")
- [6 Easy Ways to Export Data to Excel in C#](https://www.syncfusion.com/blogs/post/6-easy-ways-to-export-data-to-excel-in-c-sharp.aspx "Blog: 6 Easy Ways to Export Data to Excel in C#")
- [Seamlessly Import and Export CSV Data in Excel Using C#](https://www.syncfusion.com/blogs/post/import-export-csv-data-in-excel-csharp.aspx "Blog: Seamlessly Import and Export CSV Data in Excel Using C#")
- [Easy Steps to Export HTML Tables to Excel in C#](https://www.syncfusion.com/blogs/post/easy-steps-to-export-html-tables-to-an-excel-worksheet-in-c.aspx "Blog: Easy Steps to Export HTML Tables to Excel in C#")