Read xl java

download Read xl java

of 2

Transcript of Read xl java

  • 7/25/2019 Read xl java

    1/2

    @DataProvider(name="test") public Object[][] createdata1()throws Exception { Object[][] retobj = getexcel(); return retobj;

    }

    private String[][] getexcel() throws Exception { // TODO Auto-generated method stub

    String[][] tabarray = null; try { Workbook wb1 = Workbook.getWorkbook(new File("F:/testdata.xls"));

    Sheet sheet = wb1.getSheet("userlogin");

    Cell tablestart = sheet.findCell("login");

    int startrow = tablestart.getRow(); int startcol = tablestart.getColumn();

    Cell tableend = sheet.findCell("login",startcol+1,startrow+1,100, 64000, false);

    int endrow = tableend.getRow(); int endcol = tableend.getColumn();

    System.out.println("startRow="+startrow+", endRow="+endrow+", "+ "startCol="+startcol+", endCol="+endcol);

    tabarray = new String[endrow - startrow + 1][endcol - startcol+ 1];

    int ci = 0; for(int i = startrow +1 ;i

  • 7/25/2019 Read xl java

    2/2

    test(Dataprovider = "test")public void glogins(String user, String pass){ glogin log1 = new glogin(driver); log1.login(user,pass);}

    i have a colum in sheet 1,sheet 2 have some other column,from the sheet 1. haveto take one value and find the value in sheet 2. if value found, have to print in sheet 3.