Home » excel » Read the Data from Excel sheet into datatable without empty rows in C#

Read the Data from Excel sheet into datatable without empty rows in C#

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have a problem for reading data from Excel sheet using connection string. I am getting data. But problem is blank rows also coming. I don’t want to get blank row. Can any body help me.

Thanks in Advance.
Mehar

How to&Answers:

If there are blank rows in your sheet, you will get blank rows when you read the Excel sheet. Either remove the blank rows from your sheet or add logic to detect and ignore blank rows.

Answer:

If it’s extra rows after the data you want, you will get them if there is formatting on the cells. Select the extra range, right click and do Clear Contents.