DataReader does not see data in Excel cell if previous cell in the column are empty

不打扰是莪最后的温柔 提交于 2020-01-16 10:15:45

问题


I have a weird problem with reading .xls file using OleDbDataReader.

Basically, it does not see a data in the cell, if the previous cells in the column are empty.

If I move the row with the data at the top of Excel sheet, then everything loads fine. I'm not sure, but I think that it has something to do with the amount of empty cells before the one with data.

Any help or advice will be much appreciated.


回答1:


You probably have a connectionstring like this:

<add name="MyApp.Properties.Settings.ExcelConnectionString" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=&quot;Excel 8.0;IMEX=1;HDR=NO;TypeGuessRows=0;ImportMixedTypes=Text;&quot;;"/>

Notice the 'TypeGuessRows'. It tells Excel how many rows to scan to try to guess the datatypes of the columns. The value 0 (zero) tells it to scan all rows. Does that help you?



来源:https://stackoverflow.com/questions/12279258/datareader-does-not-see-data-in-excel-cell-if-previous-cell-in-the-column-are-em

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!