selenium - Getting error while read data from Excel sheet using Apache POI -


i'm trying read data excel file using apache poi libraries in selenium. been fiddling around ages keep getting errors.

package readexceldata;  import java.io.file;  import java.io.fileinputstream;  import java.io.ioexception;  import org.apache.poi.hssf.usermodel.hssfworkbook;  import org.apache.poi.ss.usermodel.row;  import org.apache.poi.ss.usermodel.sheet;  import org.apache.poi.ss.usermodel.workbook;  import org.apache.poi.xssf.usermodel.xssfworkbook;  public class readguru99excelfile {        public void readexcel(string filepath,string filename,string sheetname) throws ioexception{      //create object of file class open xlsx file      file file =    new file(c:\exceldata+"\\"+excelwrite);      //create object of fileinputstream class read excel file      fileinputstream inputstream = new fileinputstream(file);      workbook guru99workbook = null;      //find file extension splitting file name in substring  , getting extension name      string fileextensionname = filename.substring(filename.indexof("."));      //check condition if file xlsx file      if(fileextensionname.equals(".xlsx")){      //if xlsx file create object of xssfworkbook class      guru99workbook = new xssfworkbook(inputstream);      }      //check condition if file xls file      else if(fileextensionname.equals(".xls")){          //if xls file create object of xssfworkbook class          guru99workbook = new hssfworkbook(inputstream);      }      //read sheet inside workbook name      sheet guru99sheet = guru99workbook.getsheet(sheetname);      //find number of rows in excel file      int rowcount = guru99sheet.getlastrownum()-guru99sheet.getfirstrownum();      //create loop on rows of excel file read      (int = 0; < rowcount+1; i++) {          row row = guru99sheet.getrow(i);          //create loop print cell values in row          (int j = 0; j < row.getlastcellnum(); j++) {              //print excel data in console              system.out.print(row.getcell(j).getstringcellvalue()+"|| ");          }          system.out.println();      }        }        //main function calling readexcel function read data excel file      public static void main(string...strings) throws ioexception{      //create object of readguru99excelfile class      readguru99excelfile objexcelfile = new readguru99excelfile();      //prepare path of excel file      string filepath = system.getproperty("user.dir")+"\\src\\excelexportandfileio";      //call read file method of class read data      objexcelfile.readexcel(filepath,"exportexcel.xlsx","excelguru99demo");      }  } 

here base code. how work....

i'm trying read data excel file using apache poi libraries in selenium. been fiddling around ages keep getting errors.

"testdataexcelfile" user defined class file, not available inside package, due exception occured


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -