Re: Exporting ADOQuery Results to Excel



The following is some information from old newsgroup posts. This
subject has come up before so I suggest you use Google Groups to search
this group and you may find better information. Some of the following
refers to using the Excel ODBC driver with the BDE but using ADO should
be similar.

--
Bill Todd (TeamB)

To read an Excel work***:

Create an ODBC DSN that points to the Excel file.

Excel files will not appear in the TTable.TableName property drop-down.
Enter the work*** file name with no extension followed by a $ in the
TableName property. You can optionally append a cell range. For
exmaple: projects$A2:J1000

To read all of the rows in the work*** when specifying a cell range
make the ending row number larger than the last possible row.

If you really want to work with a table name then you can define a
named region in Excel, then that region will appear in the list of
tables




-----------------------------------------------------------
Bill Todd said something like...
|What was the secret? I would like to know. I have never tried querying
an
|Excel work***. How do you specify the range of rows and columns to be
|returned by the query.
|
It's very simple if your work*** has named ranges and the first row
of
the work*** are field names. The named ranges show up in the table
name drop down list. When using a query, refer to the named ranges, e.g.
select * from quarterly
where "quarterly" is the name of one of the ranges in the work***. If
you double click on the query icon and select the fields editor, all
the
column names in your range are displayed as field names.

If you uncheck "Read Only" option when configuring your ODBC DSN, you
can edit the work*** table.
.


Quantcast