Syncfusion Feedback

Create a Table in the Excel Worksheet with the Syncfusion .NET Excel Library

Video illustration

Watch this video to see how to create a table in the Excel worksheet using the Syncfusion .NET Excel Library:

Watch the video

Overview

The Syncfusion® .NET Excel Library (XlsIO) enables you to create, read, and edit Excel documents programmatically without Microsoft Excel or interop dependencies. Using this library, you can create a table in an Excel worksheet using C#.

Create a table in an Excel worksheet

Follow these steps to create a table in the Excel worksheet using the Syncfusion .NET Excel Library.

Step 1: Create a new project

Start by creating a new C# Console Application project.

Step 2: Install the NuGet package

Add the Syncfusion.XlsIO.Net.Core package to your project from NuGet.org.

Step 3: Include namespaces

Add the following namespaces to your Program.cs file:

using System;
using System.IO;
using Syncfusion.XlsIO;

Step 4: Add code to create a table in the Excel worksheet

Use the following code in Program.cs to create a table in the Excel worksheet.

Run

using (ExcelEngine excelEngine = new ExcelEngine())
{
	IApplication application = excelEngine.Excel;
	application.DefaultVersion = ExcelVersion.Xlsx;
	FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
	IWorkbook workbook = application.Workbooks.Open(inputStream);
	IWorksheet worksheet = workbook.Worksheets[0];
	
	//Create for the given data.
	IListObject table = worksheet.ListObjects.Create("Table1", worksheet["A1:C5"]);

	#region Save
	//Saving the workbook.
	FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/CreateTable.xlsx"), FileMode.Create, FileAccess.Write);
	workbook.SaveAs(outputStream);
	#endregion

	//Dispose streams.
	inputStream.Dispose();
	outputStream.Dispose();
}

NuGet installation

Nuget Installation image Syncfusion.XlsIO.Net.Core

Get started quickly by downloading the installer and and checking license information on the Downloads page.

Syncfusion .NET Excel Library resources

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