How to Add Named Table
A named table is also commonly known as Excel Table refers to a specific type of range that has been designated with a name and has additional functionality and properties associated with it.
How to Add Named Table
- Download the C# library to add named tables
- Select the target range with workSheet ["A1:A5"]
- Utilize
AddNamedTable
method to add named tables - Retrieve named table in various ways
- Export the edited Excel file in various formats
Install with NuGet
Install-Package IronXL.Excel
Download DLL
Manually install into your project
Install with NuGet
Install-Package IronXL.Excel
Download DLL
Manually install into your project
Start using IronPDF in your project today with a free trial.
Check out IronXL on Nuget for quick installation and deployment. With over 8 million downloads, it's transforming Excel with C#.
Install-Package IronXL.Excel
Consider installing the IronXL DLL directly. Download and manually install it for your project or GAC form: IronXL.zip
Manually install into your project
Download DLLAdd Named Table Example
To add a named table, use the AddNamedTable
method. The method requires the name of the named table as text, the range object. The user also have the option to specify the table style and whether to show the filter or not.
:path=/static-assets/excel/content-code-examples/how-to/named-table-add-named-table.cs
using IronXL;
using IronXL.Styles;
WorkBook workBook = WorkBook.Create();
WorkSheet workSheet = workBook.DefaultWorkSheet;
// Add data
workSheet["A2:C5"].StringValue = "Text";
// Configure named table
var selectedRange = workSheet["A1:C5"];
bool showFilter = false;
var tableStyle = TableStyle.TableStyleDark1;
// Add named table
workSheet.AddNamedTable("table1", selectedRange, showFilter, tableStyle);
workBook.SaveAs("addNamedTable.xlsx");
Imports IronXL
Imports IronXL.Styles
Private workBook As WorkBook = WorkBook.Create()
Private workSheet As WorkSheet = workBook.DefaultWorkSheet
' Add data
Private workSheet("A2:C5").StringValue = "Text"
' Configure named table
Private selectedRange = workSheet("A1:C5")
Private showFilter As Boolean = False
Private tableStyle = TableStyle.TableStyleDark1
' Add named table
workSheet.AddNamedTable("table1", selectedRange, showFilter, tableStyle)
workBook.SaveAs("addNamedTable.xlsx")
Retrieve Named Table Example
Retrieve All Named Table
The GetNamedTableNames
method will return all named tables in the worksheet as a list of strings.
:path=/static-assets/excel/content-code-examples/how-to/named-table-retrieve-all-named-table.cs
using IronXL;
WorkBook workBook = WorkBook.Load("addNamedTable.xlsx");
WorkSheet workSheet = workBook.DefaultWorkSheet;
// Get all named table
var namedTableList = workSheet.GetNamedTableNames();
Imports IronXL
Private workBook As WorkBook = WorkBook.Load("addNamedTable.xlsx")
Private workSheet As WorkSheet = workBook.DefaultWorkSheet
' Get all named table
Private namedTableList = workSheet.GetNamedTableNames()
Retrieve Specific Named Table
Use the GetNamedTable
method to retrieve the specific named table in the worksheet.
:path=/static-assets/excel/content-code-examples/how-to/named-table-retrieve-specific-named-table.cs
using IronXL;
WorkBook workBook = WorkBook.Load("addNamedTable.xlsx");
WorkSheet workSheet = workBook.DefaultWorkSheet;
// Get named table
var namedRangeAddress = workSheet.GetNamedTable("table1");
Imports IronXL
Private workBook As WorkBook = WorkBook.Load("addNamedTable.xlsx")
Private workSheet As WorkSheet = workBook.DefaultWorkSheet
' Get named table
Private namedRangeAddress = workSheet.GetNamedTable("table1")
IronXL can also add named ranges. Learn more at How to Add Named Range.