.NET reads the name of each sheet in Excel

xiaoxiao2021-04-04  257

OLEDBCONNECTION OBJCONN = NULL; DATATABLE DT = NULL;

try {string connString = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = D: //Readme.xls; Extended Properties = Excel 8.0;"; objConn = new OleDbConnection (connString); objConn.Open (); dt = objconn.getoledbschematable (OLEDBSChemaGuid.Tables, NULL);

IF (dt! = null) {string [] sheetname = new string [dt.rows.count]; int i = 0; Foreach (Datarow Row In Dt.Rows) {SheetName [i] = row ["Table_name"]. TOSTRING (); i ;

}}} Catch (Exception E1) {...}

转载请注明原文地址:https://www.9cbs.com/read-131774.html

New Post(0)