Board index » delphi » Delphi 2 to Excel

Delphi 2 to Excel

Are you using the Standard version of D2?  If so, it may not support ODBC.

--
Bill

(TeamB cannot answer questions received via email.)
(To contact me for any other reason remove nospam from my address)

 

Re:Delphi 2 to Excel


Quote
>Are you using the Standard version of D2?  If so, it may not support ODBC.

>--
>Bill

Standard.
Thats probably the answer Bill and I suppose its buried deep within my
manuals somewhere so I think its about time to upgrade , I'm considering
Delphi 4 Professional.
I hope most of my woes will go away.

Thanks for your help

Chris

Re:Delphi 2 to Excel


Hi,

I ran into some problems trying to access an excel97 worksheet via MS ODBC.

I created a ODBC DSN that points to the worksheet. Dropped a ttable on a form,
set the database name to the DSN. In.tablename I entered Security$A1:C20
(security.xls) is the workbook that is defined in the ODBC DSN. When I set the
table active or opened the table, I get the following message:
Table does not exist - the microsoft jet database engine could not find the
object 'Security$A1:C20'...
Also just tried Security$, or Security in the table name. Also, the tabletype is
ttDefault, correct?

Any ideas what I'm doing wrong? Using Delphi3 c/s, nt4 server

Thanks a lot!
Tom

Quote
Bill Todd (TeamB) wrote:
> The following is some information that has worked for me using the MS ODBC
> driver.
> ----------------------------------------------------------------------------
> To read an Excel worksheet:

> Create an ODBC DSN that points to the worksheet.

> Excel files will not appear in the TTable.TableName property drop-down.
> Enter the worksheet 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 worksheet when specifying a cell range make
> the ending row number larger than the last possible row.
> ----------------------------------------------------------------------

> There was a series of articles in Delphi Informant around the middle of last
> year on using Word, Excel and Access via OLE Automation.

> --
> Bill

> (TeamB cannot answer questions received via email.)
> (To contact me for any other reason remove nospam from my address)

Re:Delphi 2 to Excel


: Bill Todd (TeamB) wrote:
:
: > To read an Excel worksheet:
: >
: > Create an ODBC DSN that points to the worksheet.
: >
: > Excel files will not appear in the TTable.TableName property drop-down.

Good news. It is possible to get a drop down list of table names in
Delphi for an Excel file and here's how to do it:
In your Excel worksheet, select the range you are interested in (don't
forget to include the field names in the selection) and
give it a name. I named my range "Database." After you do this, Delphi
will give you a drop down list of table names (range names) for your
worksheet (my drop down list shows "Database").

Furthermore, if you change your odbc DSN so that the Read Only checkbox
is unchecked (it is checked by default), you can write data to your
Excel file just as you can to any other table in Delphi.

Re:Delphi 2 to Excel


Sorry.  As I said earlier in this thread I have never tried accessing an
Excel worksheet via ODBC from D2.  The instructions I posted do work for me
in D3 and that is all I can tell you.

--
Bill

(TeamB cannot answer questions received via email.)
(To contact me for any other reason remove nospam from my address)

Go to page: [1] [2]

Other Threads