I have an excell sheet named "Test File.xlsx". I want to get the values in the cells of the sheet and store every individual values in different randomly generated variables. And later on compare the value in those variables on different pages of my site with the values already stored in there.
The data is numeric in some columns and string in other columns. e.g. first column has alphanumeric data , the 2nd column has int data and the third has string data.
I have read the following code but it seems only to store data in array. kindly help as i am new to selenium. I am using Java, selenium, win 8, IE10.
`import java.io.IOException; import jxl.Cell; import jxl.Sheet; import jxl.Workbook; import jxl.read.biff.BiffException; public class NewExcel { private String inputFile; String[][] data = null; public void setInputFile(String inputFile) { this.inputFile = inputFile; } public String[][] read() throws IOException { File inputWorkbook = new File(inputFile); Workbook w; try { w = Workbook.getWorkbook(inputWorkbook); data = new String[sheet.getColumns()][sheet.getRows()]; // Loop over first 10 column and lines // System.out.println(sheet.getColumns() + " " +sheet.getRows()); for (int j = 0; j <sheet.getColumns(); j++) { for (int i = 0; i < sheet.getRows(); i++) { Cell cell = sheet.getCell(j, i); data[j][i] = cell.getContents();// System.out.println(cell.getContents());} } /* for (int j = 0; j < data.length; j++) { for (int i = 0; i <data[j].length; i++) { System.out.println(data[j][i]); } } */ } catch (BiffException e) { e.printStackTrace(); } return data; } } public static void main(String[] args) throws IOException { NewExcel test = new NewExcel(); test.setInputFile("D:\\Haseeb\\Test file.xlsx"); test.read(); } }`
but i am using it selenium, can you please help with the java code??
but i am using it selenium, can you please help with the java code??
--To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/ff136819-d963-4e99-ae3a-e67f9c5108cb%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.