Excel Reader Class file | Selenium Webdriver Tutorial with c# |Selenium C# training

Selenium C# Training Forum

Excel Reader Class file

A
Aswath Bava Post 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;
else
{
sheet = workbook.GetSheetAt(index);
int number = sheet.LastRowNum + 1;
return number;
}
}

G

Instructor

gunjan Reply 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.