我试图在Excel工作手册中检索一份工作表列表,但我收到的收藏有工作表名称和数据列 id s,它们似乎在原xlsxxxml中被称为定义名称。你能告诉我如何只返回工作表名称吗?
Im使用的代码大致如下:
OleDbConnection connExcel = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;"
+ @"Data Source=" + FilePath + ";"
+ @"Extended Properties=""Excel 8.0;HDR=Yes;""");
OleDbCommand cmdExcel = new OleDbCommand();
cmdExcel.Connection = connExcel;
connExcel.Open();
DataTable testTable = connExcel.GetSchema("Tables");
由此得出的测试表收集内容包含下列表表下条目:
- DATA1
- DATA2
- DATA3
- DATA4
- DATA5
- Sheet1$
- TEST1 -TEST2
- TESTHKEY
- TESTKEYS
- TESTVKEY
他们都有一个Table的Table类型。
The original workbook corresponding to the above would have 1 worksheet containing 5 columns, the first row would contain a header. I m only interested in the Sheet1$ entry. The spreadsheet is created in Excel 2010, I m trying to process it in an ASP.NET 4 app written in C#. Potentially, the worksheet name may have been changed so I can t guarrantee that it will always be Sheet1$.