Board index » delphi » Get list of Excel Worksheets with ADO

Get list of Excel Worksheets with ADO


2003-12-18 01:16:58 AM
delphi125
Need to be able to get a list of Worksheets in
an Excel Workbook with ADO.
ADOConnection1.ConnectionString :=
'Provider=MSDASQL.1;Persist ' +
'Security Info=False;Extended ' +
'Properties="DSN=My_Excel_File;' +
'DBQ=MyExcelFile.xls;DefaultDir=C:;' +
'DriverId=790;FIL=excel 8.0;' +
'MaxBufferSize=2048;PageTimeout=5;"';
ADOConnection1.Open;
ADOConnection1.GetTableNames(ExcelWorkBookNames);
Doesn't work...
 
 

Re:Get list of Excel Worksheets with ADO

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\File.xls;Extended
properties=Excel 8.0
//------------------------------------------
Regards,
Vassiliev V. V.
www.managed-vcl.com - using .Net objects in Delphi + ADO.Net
www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"eshipman" <eshipman@yahoo!!!.com>???????/???????? ? ???????? ?????????:
Quote
Need to be able to get a list of Worksheets in
an Excel Workbook with ADO.

ADOConnection1.ConnectionString :=
'Provider=MSDASQL.1;Persist ' +
'Security Info=False;Extended ' +
'Properties="DSN=My_Excel_File;' +
'DBQ=MyExcelFile.xls;DefaultDir=C:;' +
'DriverId=790;FIL=excel 8.0;' +
'MaxBufferSize=2048;PageTimeout=5;"';
ADOConnection1.Open;
ADOConnection1.GetTableNames(ExcelWorkBookNames);

Doesn't work...
 

Re:Get list of Excel Worksheets with ADO

In article <XXXX@XXXXX.COM>, XXXX@XXXXX.COM
says...
Quote
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\File.xls;Extended
properties=Excel 8.0

"eshipman" <eshipman@yahoo!!!.com>???????/???????? ? ???????? ?????????:
news:XXXX@XXXXX.COM...
>Need to be able to get a list of Worksheets in
>an Excel Workbook with ADO.
>
>ADOConnection1.ConnectionString :=
>'Provider=MSDASQL.1;Persist ' +
>'Security Info=False;Extended ' +
>'Properties="DSN=My_Excel_File;' +
>'DBQ=MyExcelFile.xls;DefaultDir=C:;' +
>'DriverId=790;FIL=excel 8.0;' +
>'MaxBufferSize=2048;PageTimeout=5;"';
>ADOConnection1.Open;
>ADOConnection1.GetTableNames(ExcelWorkBookNames);
>
>Doesn't work...

ADOConnection1.ConnectionString :=
'Provider=Microsoft.Jet.OLEDB.4.0;Persist ' +
'Security Info=False;Extended ' +
'Properties="DSN=My_Excel_File;' +
'DBQ=MyExcelFile.xls;DefaultDir=C:;' +
'DriverId=790;FIL=excel 8.0;' +
'MaxBufferSize=2048;PageTimeout=5;"';
Now, after that change, I get this error:
'Could not find installable ISAM'
 

Re:Get list of Excel Worksheets with ADO

No, exactly as I sayd, no DSN, no ODBC:
ADOConnection1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\File.xls;Extended properties=Excel 8.0';
(without line breaks).
//------------------------------------------
Regards,
Vassiliev V. V.
www.managed-vcl.com - using .Net objects in Delphi + ADO.Net
www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"eshipman" <eshipman@yahoo!!!.com>???????/???????? ? ???????? ?????????:
Quote
In article <XXXX@XXXXX.COM>, XXXX@XXXXX.COM
says...
>Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\File.xls;Extended
>properties=Excel 8.0
>
>"eshipman" <eshipman@yahoo!!!.com>???????/???????? ? ????????
?????????:
>news:XXXX@XXXXX.COM...
>>Need to be able to get a list of Worksheets in
>>an Excel Workbook with ADO.
>>
>>ADOConnection1.ConnectionString :=
>>'Provider=MSDASQL.1;Persist ' +
>>'Security Info=False;Extended ' +
>>'Properties="DSN=My_Excel_File;' +
>>'DBQ=MyExcelFile.xls;DefaultDir=C:;' +
>>'DriverId=790;FIL=excel 8.0;' +
>>'MaxBufferSize=2048;PageTimeout=5;"';
>>ADOConnection1.Open;
>>ADOConnection1.GetTableNames(ExcelWorkBookNames);
>>
>>Doesn't work...
>
ADOConnection1.ConnectionString :=
'Provider=Microsoft.Jet.OLEDB.4.0;Persist ' +
'Security Info=False;Extended ' +
'Properties="DSN=My_Excel_File;' +
'DBQ=MyExcelFile.xls;DefaultDir=C:;' +
'DriverId=790;FIL=excel 8.0;' +
'MaxBufferSize=2048;PageTimeout=5;"';


Now, after that change, I get this error:
'Could not find installable ISAM'
 

Re:Get list of Excel Worksheets with ADO

In article <XXXX@XXXXX.COM>,
eshipman@yahoo!!!.com says...
Quote
Need to be able to get a list of Worksheets in
an Excel Workbook with ADO.

ADOConnection1.ConnectionString :=
'Provider=MSDASQL.1;Persist ' +
'Security Info=False;Extended ' +
'Properties="DSN=My_Excel_File;' +
'DBQ=MyExcelFile.xls;DefaultDir=C:;' +
'DriverId=790;FIL=excel 8.0;' +
'MaxBufferSize=2048;PageTimeout=5;"';
ADOConnection1.Open;
ADOConnection1.GetTableNames(ExcelWorkBookNames);

Doesn't work...

This works:
ADOConnection1.ConnectionString :=
'Provider=MSDASQL.1;Persist ' +
'Security Info=False;Extended ' +
'Properties="DSN=My_Excel_File;' +
'DBQ=MyExcelFile.xls;DefaultDir=C:;' +
'DriverId=790;FIL=excel 8.0;' +
'MaxBufferSize=2048;PageTimeout=5;"';
ADOConnection1.Open;
ADOConnection1.OpenSchema(siTables, EmptyParam,
EmptyParam, ADODataSet1);
ADODataSet1.DisableControls;
ADODataSet1.Open;
while not ADODataset1.Eof do
begin
ExcelWorkBookNames.Add(ADODataSet1.fields[2].value);
ADODataset1.Next;
end;
ADODataset1.Close;
ADODataSet1.EnableControls;
ADOConnection1.Close;