Excel values to datatable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I am exporting excel worksheet values into datatable. When there is a value
in the excel cell which has more than 2 decimal places, for example say
123456789.123, the datatable truncates this to just two decimal places
(123456789.12) losing the the third decimal place. Is there a workaround for
this?. Thanks in advance.
 
¤ Hi
¤ I am exporting excel worksheet values into datatable. When there is a value
¤ in the excel cell which has more than 2 decimal places, for example say
¤ 123456789.123, the datatable truncates this to just two decimal places
¤ (123456789.12) losing the the third decimal place. Is there a workaround for
¤ this?. Thanks in advance.

The Excel ISAM driver has to make some guesswork in order to determine the data types for fields.
Since this involves scanning a limited number of rows you don't always end up with the proper
result.

I wasn't able to repro your problem but it could be because you're working with a larger set of
data. Try adding the IMEX parameter to your connection string:

Example:

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\Book20.xls;" & _
"Extended Properties=""Excel 8.0;HDR=No;IMEX=1"""

If this doesn't work you may want to indicate where you see the data being truncated.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top