Get Excel sheet name using ClosedXML in C# and VB.Net

Last Reply 4 months ago By pandeyism

Posted 4 months ago

How to get the excel sheet name in c#?

Posted 4 months ago

Hi SUJAYS,

Refer below link there is writen code how to get sheet name.

And refer below code same as link code.

Export Excel with multiple sheets to multiple DataTables using ClosedXML in Windows Application

C#

foreach (IXLWorksheet workSheet in workBook.Worksheets)
{
    DataTable dt = new DataTable();
    IXLWorksheet worksheet = workBook.Worksheet(workSheet.Name);
    dt.TableName = workSheet.Name;
}

VB.Net

For Each workSheet As IXLWorksheet In workBook.Worksheets
    Dim dt As DataTable = New DataTable()
    Dim worksheet As IXLWorksheet = workBook.Worksheet(workSheet.Name)
    dt.TableName = workSheet.Name
Next