Re: Pulling From Excel Files

From: treok (h.k.j.keesmaat_at_chello.nl)
Date: 02/17/05


Date: Thu, 17 Feb 2005 11:25:34 +0100

set the extended properties of your ADOConnection to

"Excel 8.0;HDR=No;IMEX=1"

>Hi Everyone,
>
>I'm having a problem and I hope that someone has ran into this before.
I am
>using the ADOTable function to pull data out of an MS excel
spread***. I
>have used this before and didn't have any problems pulling numbers, but
now
>I am having problems because I want to pull text(strings) as well as
>integers from it. I am using Delphi 7. I set up a test to try and
trouble
>shoot the problem. Here is my code:
>
> ADOTable.tablename := '[Spectrum data$]';
> ADOTable.active := True;
>
> ADOTable.First;
>
> EpiName := ADOTable.Fields.FieldByNumber(1).AsString;
> ADOTable.Next;
> EpiName := ADOTable.Fields.FieldByNumber(1).AsString;
> ADOTable.Next;
> EpiName := ADOTable.Fields.FieldByNumber(1).AsString;
> ADOTable.Next;
> EpiName := ADOTable.Fields.FieldByNumber(1).AsString;
> ADOTable.Next;
> EpiName := ADOTable.Fields.FieldByNumber(1).AsString;
> ADOTable.Next;
> EpiName := ADOTable.Fields.FieldByNumber(1).AsString;
> ADOTable.Next;
> EpiName := ADOTable.Fields.FieldByNumber(1).AsString;
> ADOTable.Next;
> EpiName := ADOTable.Fields.FieldByNumber(1).AsString;
> ADOTable.Next;
> EpiName := ADOTable.Fields.FieldByNumber(1).AsString;
> ADOTable.Next;
> EpiName := ADOTable.Fields.FieldByNumber(1).AsString;
>
>In the Excel *** that I am trying to pull from I have this data:
> one
> two
> three
> four
> five
> 1
> 2
> 3
> 4
> 5
>
>
>It reads the '1', '2', '3', '4', '5' fine as string values. But
the 'one',
>'two', etc are being passed back as empty strings ' '. I have tried
>typecasting and also formatting the cells of the excel spread*** to
text.
>But still no luck. Please any help will be grateful. Thanks.
>
>Shayne
>
>
>

--- posted by geoForum on http://delphi.newswhat.com