Articles in this section
Category / Section

How to change the table column name and update the named range in C#, VB.NET

1 min read

Syncfusion Excel (XlsIO) library is a .NET Excel library used to create, read, and edit Excel documents.

This article explains how to modify the table column header name which in-turn modifies the table column header named range. Name property of IListObjectColumn is used to achieve this.

C#

using Syncfusion.XlsIO;
 
namespace ChangeTableColumnName
{
    class Program
    {
        static void Main(string[] args)
        {
            using(ExcelEngine excelEngine = new ExcelEngine())
            {
                IApplication application = excelEngine.Excel;
                application.DefaultVersion = ExcelVersion.Excel2016;
 
                IWorkbook workbook = application.Workbooks.Open("../../Data/Sample.xlsx");
                IWorksheet worksheet = workbook.Worksheets[0];
 
                IListObject table = worksheet.ListObjects[0];
 
                table.Columns[1].Name = "NewName";
 
                workbook.SaveAs("Output.xlsx");
                System.Diagnostics.Process.Start("Output.xlsx");
            }
        }
    }
}

 

A complete working sample can be downloaded from ChangeTableColumnName.zip.

The input Excel document look like,

input Excel document

Table column name

The output Excel document look like,

output Excel document

Table column name changed

Take a moment to peruse the documentation, where you can find basic worksheet data manipulation options along with features like Conditional Formatting, worksheet calculations through Formulas, adding Charts in worksheet or workbook, organizing and analyzing data through Tables and Pivot Tables, appending multiple records to worksheet using Template Markers, and most importantly PDF and Image conversions etc. with code examples.

Click here to explore the rich set of Syncfusion Excel (XlsIO) library features.

Note:

Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer the link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied