Excel Reader Class file | Selenium C# Forum
Aswath Bava Posted on 08/08/2019

In the excel Reader class file , when I call getrowcount method, why do i get a count of (-1). I should get a count of 5 rows . How can i fix it?


I look at the method written for it , why does it say -1, 

public int getRowCount(string sheetName)
int index = workbook.GetSheetIndex(sheetName);
if (index == -1)
return 0;
sheet = workbook.GetSheetAt(index);
int number = sheet.LastRowNum + 1;
return number;

gunjan Replied on 17/08/2019

Please add a new Excel file and then try again. And also, make sure you close the excel file while executing your code.