locked
Sheet Names from EXCEL RRS feed

  • Question

  •  I want to read the sheetnames from a excel spread sheet and i want it to appear in the same order as they exist in the spread sheet. We do not have excel installed and have to rely on ADO .Net to do this. The current result is sorted. Any help will be very appreciated.

    myExcelConn = new OleDbConnection(strExcelConn);

    myExcelConn.Open();

    dt = myExcelConn.GetOleDbSchemaTable (OleDbSchemaGuid..Tables, null);

    myExcelConn.Close();

    String[] sheets123 = new String[dt.Rows.Count];

    int num = 0;

    // Add the sheet name to the string array.

    foreach(DataRow row in dt.Rows)

    {

    sheets123[num] = row["TABLE_NAME"].ToString();

    num++;

    }


    SRI
    • Moved by jack 321 Tuesday, June 3, 2008 5:56 AM off topic for C# general
    Friday, May 30, 2008 5:46 AM

Answers