c# - Get all sheet names in an Excel file in order -


this question has answer here:

i trying sheet names in same order in excel file array. reach sheet individually below:

var pathtoexcel = @"c:\users\desktop\everything.xlsx"; var sheetname = "sheet 1"; var destinationpath = @"c:\users\desktop\sheet1.json"; var connectionstring = string.format(@"             provider=microsoft.ace.oledb.12.0;             data source={0};             extended properties=""excel 12.0 xml;hdr=yes""         ", pathtoexcel); 

i wondering how sheet names in array.

try this,

oledbconnection conn = new oledbconnection(connectionstring); conn.open(); datatable dt = conn.getoledbschematable(oledbschemaguid.tables, null); string[] sheetnames = new string[dt.rows.count]; int = 0; foreach (datarow row in dt.rows) {    sheetnames[i] = row["table_name"].tostring();    i++; } 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -