0

i am using the following connectionstring

Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Convert.ToString(pa) + ";" + "Extended Properties=Excel 8.0

but when a column contains only numeric value it reads it as empty

any idea? kindly help

vakas
  • 1,799
  • 5
  • 23
  • 40
  • 2
    does your excel column contain only numeric values or does it also include string values? If there is a header for the columns then you have to use `HDR=1;` option in the connection string. – Devendra D. Chavan Mar 02 '11 at 13:12
  • @Devendra: it may include string and numeric values as well,Headers are not mandatory.. but while reading i get the 1st row as header row.but if i set HDR=1 then always 1st row will be treated as header.if 1st row is empty then 2nd row will be treated as header,but y the numeric values are not read? – vakas Mar 02 '11 at 17:20

1 Answers1

0

Read this blog post

http://blog.lab49.com/archives/196

to understand better what is happening here. To make it short: using OleDb to read Excel sheets is very unreliable by (bad!) design. Here is a much better alternative (for the old non-XML Excel file format):

http://jexcelapi.sourceforge.net/

(under the Files section you will find a C# port of this Java library).

Doc Brown
  • 19,739
  • 7
  • 52
  • 88