How to get list of ONLY excel worksheet names in Excel using OLEDB; filter out non-worksheets that show up in metadata

前端 未结 4 2226
眼角桃花
眼角桃花 2020-12-28 22:05

I have an issue getting worksheet names from an Excel spreadsheet using OLEDB. The problem is that when I use GetOleDbSchemaTable, the resulting DataTable has more than jus

4条回答
  •  孤独总比滥情好
    2020-12-28 22:27

    The question is old, but for those who found it now, the skipping can be done as Jim found...

    // skip those that do not end correctly
    foreach (DataRow row in schemTable.Rows)
    {
        string sheetName = row["TABLE_NAME"].ToString();
        if (!sheetName.EndsWith("$") && !sheetName.EndsWith("$'"))
            continue;
        Console.WriteLine(sheetName);
    }
    

    That is the wanted are or those that end with $ or those that end with $'.

提交回复
热议问题