0
votes

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

1
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
@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

1 Answers

0
votes

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).