Selenium - Reading Excel File using Java - JXL Package

Selenium - Reading Excel File using Java - JXL Package

package com.ExcelPackage;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import jxl.Sheet;
import java.io.IOException;
import java.io.FileInputStream;
public class ExcelTest
{
 public void readexcel() throws BiffException,IOException
 {
  String filename1 = "C:\\Delmelater\\SmithDataTableTests.xls";
  FileInputStream fs = new FileInputStream(filename1);
  Workbook wb = Workbook.getWorkbook(fs);
  Sheet sh1 = wb.getSheet("Login");
  int v1 = sh1.getRows();
  System.out.println(v1);
  int v2 = sh1.getColumns();
  System.out.println(v2);

  for(int p= 1; p<=v1; p++)
  {
   for(int p1=1;p1<=v2;p1++)
   {
   String c1 = sh1.getCell(p, p1).getContents();
   System.out.println(c1);
   }
  }
 }

 public static void main(String args[])
 {
  ExcelTest b1 = new ExcelTest();
  try
  {
  b1.readexcel();
  }
  catch(Exception e)
  {
   System.out.println(e);
  }
 }
}

No comments:

Post a Comment