Developers community number 1 connection string reference

Sheet's names

Posted 2010-09-14 15:22
by Dadou Di
in the Excel Forum
Hi,

I want to create a DataSet from an excel without knowing the name(s) of the sheets inside.

Is it possible to get the names of the sheets using OLE DB Provider ? So a I can perform several SELECT orders to get each sheets as a DataTable, then insert it into a DataSet.

If you know an easiet way to get a DataSet from an excel file, please do not hesitate.

Thank you.
Dadou
Reply 2010-09-24 14:16
by Fabio La Vitola
in the Excel Forum
Hi,
if you mean something like (my VB6 sample)


With ExcelConn

.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ExcelFileName & ";Extended Properties=""Excel 12.0;HDR=YES;IMEX=0;ParamCheck=False"""

.CursorLocation = adUseClient
.Open

Set ExcelSchema = .OpenSchema(adSchemaTables)

end with

-------------------------------------------------
i've solved with

note that ExcelSchema recordset contains now the n# of sheets and the sheet names are stored into ExcelSchema.Fields("TABLE_NAME").Value
----------------------------
Hope being of help...
By !
Copyright © 2012 ConnectionStrings.com   |   All Rights Reserved   |   Powered by CSAS   |   Send feedback, articles, requests and more connection strings here.