IRONSOFTWAREHOME

How to Add Named Table in Excel Using C#

Curtis Chau
Curtis Chau
Updated: August 2, 2026

To add a named table in Excel using C#, use IronXL's AddNamedTable method with parameters for table name, range, and optional styling - enabling structured data management with a single method call.

A named table is also commonly known as an Excel Table, which refers to a specific type of range that has been designated with a name and has additional functionality and properties associated with it. Named tables provide enhanced data organization capabilities, automatic formatting, built-in filtering, and seamless integration with Excel formulas - making them essential for managing structured datasets in Excel automation workflows.

Quickstart: Create and Name a Table in One Line

This example shows how effortlessly you can add a named table in your worksheet using IronXL - define the name, range, filter visibility, and style all in a single clear method call.

  1. 1Install IronXL with NuGet Package Manager

    PM > Install-Package IronXL.Excel

  2. 2Copy and run this code snippet.

    var table = workSheet.AddNamedTable("MyTable", workSheet.GetRange("A1:B5"), showFilter: true, tableStyle: IronXL.Styles.TableStyle.TableStyleMedium2);
    C#
  3. 3Deploy to test on your live environment

    Start using IronXL in your project today with a free trial
    arrow pointer

How Do I Add a Named Table to My Excel Worksheet?

To add a named table, use the AddNamedTable method. The method requires the name of the table as a string and the range object. You also have the option to specify the table style and whether to show the filter. This functionality is particularly useful when working with DataSet and DataTable imports where structured data needs proper organization.

// Example code to add a named table using IronXL
using IronXL;
using IronXL.Styles;

// Load the Excel workbook
var workbook = WorkBook.Load("example.xlsx");
// Select the worksheet
var workSheet = workbook.WorkSheets.First();

// Define the range for the named table
var range = workSheet["A1:B10"];

// Add a named table with the specified name and range
var namedTable = workSheet.AddNamedTable("MyTable", range);

// Optionally, set table style and visibility of the filter
namedTable.SetStyle(TableStyle.TableStyleDark10);
namedTable.ShowFilter = true;

// Save the modified workbook
workbook.SaveAs("modified_example.xlsx");
C#

Named tables support various styling options through the TableStyle class. You can apply professional formatting instantly, which complements other formatting features like cell styling and borders. Here's an example demonstrating different table style applications:

// Example: Creating multiple styled named tables
using IronXL;
using IronXL.Styles;

var workbook = WorkBook.Create();
var sheet = workbook.CreateWorkSheet("SalesData");

// Add sample data
sheet["A1"].Value = "Product";
sheet["B1"].Value = "Sales";
sheet["C1"].Value = "Revenue";

// Populate data rows
for (int i = 2; i <= 10; i++)
{
    sheet[$"A{i}"].Value = $"Product {i-1}";
    sheet[$"B{i}"].IntValue = i * 100;
    sheet[$"C{i}"].DecimalValue = i * 250.50m;
}

// Create a light-styled table
var salesTable = sheet.AddNamedTable("SalesTable", sheet["A1:C10"], 
    showFilter: true, 
    tableStyle: TableStyle.TableStyleLight15);

// Create another table with dark styling
sheet["E1"].Value = "Region";
sheet["F1"].Value = "Performance";
var regionTable = sheet.AddNamedTable("RegionData", sheet["E1:F5"], 
    showFilter: false, 
    tableStyle: TableStyle.TableStyleDark3);

workbook.SaveAs("styled_tables.xlsx");
C#
Excel spreadsheet showing a named table with three columns and formatted headers containing sample text data

How Can I Retrieve Named Tables from My Worksheet?

What Method Returns All Named Tables in a Worksheet?

The GetNamedTableNames method returns all named tables in the worksheet as a list of strings. This is particularly useful when working with workbooks containing multiple tables or when managing worksheets with dynamic data structures.

// Example code to retrieve all named table names using IronXL
using IronXL;

// Load the Excel workbook
var workbook = WorkBook.Load("example.xlsx");
// Select the worksheet
var workSheet = workbook.WorkSheets.First();

// Retrieve all named table names
var tableNames = workSheet.GetNamedTableNames();

// Output each table name
foreach (var name in tableNames)
{
    Console.WriteLine("Named Table: " + name);
}

How Do I Access a Specific Named Table by Its Name?

Use the GetNamedTable method to retrieve a specific named table in the worksheet. Once retrieved, you can access various properties and perform operations like sorting cell ranges or applying conditional formatting.

// Example code to retrieve a specific named table using IronXL
using IronXL;

// Load the Excel workbook
var workbook = WorkBook.Load("example.xlsx");
// Select the worksheet
var workSheet = workbook.WorkSheets.First();

// Retrieve a specific named table
var namedTable = workSheet.GetNamedTable("MyTable");

// Output some information about the table
Console.WriteLine("Named Table: " + namedTable.Name);
Console.WriteLine("Rows: " + namedTable.Rows);

Working with Table Data

Named tables provide powerful data manipulation capabilities. Here's a comprehensive example showing how to work with table data:

// Advanced named table operations
using IronXL;
using System.Linq;

var workbook = WorkBook.Load("sales_data.xlsx");
var sheet = workbook.DefaultWorkSheet;

// Create a named table from existing data
var dataRange = sheet["A1:D20"];
var salesTable = sheet.AddNamedTable("MonthlySales", dataRange, true);

// Access table data for calculations
var tableRange = salesTable.TableRange;

// Sum values in a specific column (assuming column C contains numeric data)
decimal totalSales = 0;
for (int row = 2; row <= tableRange.RowCount; row++)
{
    var cellValue = sheet[$"C{row}"].DecimalValue;
    totalSales += cellValue;
}

// Add summary row
var summaryRow = tableRange.RowCount + 1;
sheet[$"B{summaryRow}"].Value = "Total:";
sheet[$"C{summaryRow}"].Value = totalSales;

// Apply formatting to the summary row
sheet[$"B{summaryRow}:D{summaryRow}"].Style.Font.Bold = true;
sheet[$"B{summaryRow}:D{summaryRow}"].Style.SetBackgroundColor("#FFE599");

workbook.SaveAs("sales_with_summary.xlsx");

Integration with Other IronXL Features

Named tables work seamlessly with other IronXL features. You can combine them with formulas for dynamic calculations or use them as data sources when creating charts. They're also excellent for organizing data before exporting to different formats.

// Example: Named table with formulas
using IronXL;
using IronXL.Styles;

var workbook = WorkBook.Create();
var sheet = workbook.CreateWorkSheet("Analysis");

// Create data structure
sheet["A1"].Value = "Item";
sheet["B1"].Value = "Quantity";
sheet["C1"].Value = "Price";
sheet["D1"].Value = "Total";

// Add sample data
for (int i = 2; i <= 6; i++)
{
    sheet[$"A{i}"].Value = $"Item {i-1}";
    sheet[$"B{i}"].IntValue = i * 10;
    sheet[$"C{i}"].DecimalValue = i * 15.99m;
    // Add formula to calculate total
    sheet[$"D{i}"].Formula = $"=B{i}*C{i}";
}

// Create named table including the formula column
var priceTable = sheet.AddNamedTable("PriceCalculations", sheet["A1:D6"], 
    showFilter: true, 
    tableStyle: TableStyle.TableStyleMedium9);

// Add a grand total formula
sheet["C7"].Value = "Grand Total:";
sheet["D7"].Formula = "=SUM(D2:D6)";
sheet["D7"].Style.Font.Bold = true;

workbook.SaveAs("table_with_formulas.xlsx");
C#

IronXL can also add named ranges. Learn more at How to Add Named Range.

Frequently Asked Questions

How can I create a named table in Excel using C# with IronXL?

You can create a named table in Excel using C# by leveraging IronXL's AddNamedTable method. This method allows you to define parameters such as table name, range, and optional styling, enabling structured data management with just a single method call.

What is a named table in Excel, and why is it useful?

A named table in Excel, also known as an Excel Table, is a range that has been designated with a name and provides functionalities like automatic formatting, built-in filtering, and ease of use with Excel formulas. It enhances data organization and management, especially useful for structured datasets in Excel automation workflows.

What are the benefits of using IronXL for managing named tables in C# projects?

IronXL offers simplicity and efficiency for managing named tables. With methods like AddNamedTable, developers can quickly create tables with custom styles and filters, manage structured data, and integrate seamlessly with other Excel features like formulas and data exports.

Can I apply different styles to named tables using IronXL?

Yes, IronXL allows you to apply various styles to named tables through the TableStyle class. You can instantly set professional formats to tables, including light and dark styles, that complement other formatting features such as cell styling and borders.

How can I retrieve all named tables from a worksheet using IronXL?

To retrieve all named tables from a worksheet, use IronXL's GetNamedTableNames method. It returns a list of strings representing the names of all named tables present, which is useful for managing workbooks with multiple tables or dynamic data structures.

Is it possible to access and manipulate a specific named table by its name in IronXL?

Yes, you can access a specific named table by using IronXL's GetNamedTable method. Once accessed, you can manipulate its properties or perform operations such as sorting or formatting.

How do named tables in IronXL enhance data manipulation capabilities?

Named tables in IronXL offer powerful data manipulation capabilities. They allow for advanced operations like summing column values programmatically, adding summary rows, and applying conditional formatting, making them valuable for comprehensive Excel data management.

Can I integrate named tables with other features in IronXL?

Yes, named tables seamlessly integrate with other IronXL features. You can use them in conjunction with formulas for dynamic calculations, as data sources for creating charts, or as organized data structures before exporting to different formats.

How do I include formulas within a named table using IronXL?

When adding a named table with IronXL, you can include columns with formulas. For instance, you can calculate totals for each row based on other column values and then add grand total formulas below the data rows for comprehensive data analysis.

Where can I learn more about adding named ranges using IronXL?

You can learn more about adding named ranges in IronXL by visiting their documentation page on 'How to Add Named Range'. This section offers insights into creating and managing named ranges within Excel workbooks programmatically.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 2,237,574Version:2026.9just released

Get your FREE

30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
bullet_testTest in production
without watermarks
bullet_calendar30 days fully
functional product
bullet_support24/5 technical
support during trial
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronXL.Excel
nuget.org/packages/IronXL.Excel/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronXL"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

  1. Download and unzip IronXL to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronXL.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required