Problems in reading excel data

  • Thread starter Thread starter Sunit Joshi
  • Start date Start date
S

Sunit Joshi

Hello All
I'm having some problems in reading excel data. The connection string
is like this

connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source={0};Extended Properties="
connectionString += "\"Excel 8.0;HDR={1};IMEX=1;ReadOnly=0;\"";

It's not reading data which has an F appended to it (with any
Alpohabet as suffix), like in 49844F or 32535X which is in coln called
STOCK_NO. Any other numeric data, like 49929 is being read fine.

This coln is being read into a column of type string and it's coming
in as empty string since the resultant DataSet's xml is looking like
this

<MASTER>
<RECD_DTE>2004-07-06T00:00:00.0000000-05:00</RECD_DTE>
<STOCK_NO />
<MANUF_PRICE>42565</MANUF_PRICE>
<INV_AMT>29960</INV_AMT>
<LOW_PRICE>29661</LOW_PRICE>
<SAVINGS>12904</SAVINGS>
</MASTER>
<MASTER>
<RECD_DTE>2004-07-02T00:00:00.0000000-05:00</RECD_DTE>
<STOCK_NO>49929</STOCK_NO>
<MANUF_PRICE>47140</MANUF_PRICE>
<INV_AMT>40212</INV_AMT>
<LOW_PRICE>37810</LOW_PRICE>
<SAVINGS>9330</SAVINGS>
</MASTER>

Any help is greatly appreciated.

thanks
Sunit
 
It's the provider treating the column as numeric. You are loosing the values
becaue they are not numeric. One way to overcome this is--use a schema.ini
file in the same folder of the .xls file and define the column type
appropriately. You have much more freedom including type conversion to
select data from the file. Use of schema could be rather complex if the
file(or the columns in it) is dynamic.
 
Thanks for the info...can you point to documentation on this schema.ini
file...??

thanks
Sunit
 
Back
Top