Free Support Forum -

worksheet.Cells.Rows.Count probelm


I have a excel file. when i try to count the rows number, its return 1 more than the original one.

I have checked the file several times but there is only 10 rows. but its return 11.

Here is the sample code:


Worksheet worksheet = workbook.Worksheets[0];

int rowCount = worksheet.Cells.Rows.Count ;

Is it possible to count a blank row? Whats the problem?

Plz help me out.

Thanks in advanced


Hi Mamun,

Please post your sample file. We will check it soon.

Hi warren, plz find the attachement for wrong count file.

Hi warren, plz find the attachement file for the right count file.


Please use Cells.MaxDataRow - Cells.MinRow + 1 to get the row count.

It doesnt work for me....for both file it returns same row count which is not correct....

Is there any other way?


Do you means that you want to ignore all blank rows ? Now we have no according method to get such row count.

Please explain your need. We will check if we have another solution to serve your need.