Search code examples
c#.netexceloledb

How can I dodge empty rows in an Excel file with OleDB?


I start to use OleDB. I'm trying to extract a large range of random data from an Excel file (in C#). This my query :

SELECT * FROM NAMED_RANGE

But I have a lot of empty rows. I delete them in a loop but I don't really like it, is it possible to select only rows with at least one cell filled ?

Best regards,

Alex


Solution

  • Simply change the SQL Query:

    SELECT * FROM NAMED_RANGE WHERE [YourColumnTitle] IS NOT NULL
    

    Or if [F1] is your Column:

    SELECT * FROM NAMED_RANGE WHERE F1 IS NOT NULL
    

    Thanks to mr.Reband