Question

I'm using the OLEDB Connection to reading an excel document, that document has data up to 100 rows. but when i delete 5 rows then try to read the document again, that OLEDB reader reading up to 100 rows not 95. then throws an exception. I'm wondering why it's reading up to 100 rows because there is only 95 rows are exists.

Was it helpful?

Solution

In many cases, Excel will 'remember' that there used to be data in those 5 rows, so they are included in the query results. (This is assuming that you just deleted the contents of the rows). A simple fix for this is to delete the entire row, not just the contents of the row from the Excel spreadsheet; then save and close the spreadsheet. In the cases that I have tested, this removes those 'empty' rows from the query results.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top