我有一个类"应用程序",它有数组变量让我们说文档[]文档。 另外,我创建了另外两个类" User"和"销售"有自己的一组变量。
现在,在我的Excel工作簿上,我有三张应用程序,用户和销售。
在selenium自动化代码上,当我尝试阅读销售数据时读取用户数据后,它表示无法识别销售数据(无法识别excel表sale1)。
请帮忙。
申请类
ID Application1文档
E42421申请人1 user1,sale1
用户类
键头到尾
user1 sara kin
销售类
关键业务销售
sale1 steel 20000
答案 0 :(得分:0)
As far as I got ur question, its regarding reading the data from each sheet in an existing excel sheet, try the below one, you can read the while data in a 2 D array:
Workbook book = Workbook.getWorkbook(new File(fileNameWithLocation));
Sheet sheet = book.getSheet(0); //or book.getSheet(sheetName);
//CellFinder cellFind = new CellFinder(sheet);
String [][]testDataProvider = new String[sheet.getRows()][sheet.getColumns()];
for(int row=0;row<sheet.getRows();row++)
{
//c=0 is fileLocation passed in method FetchDataFromExcelSheet, so counting from c=1
for (int col = 0; col < sheet.getColumns(); col++)
{
String data = sheet.getCell(col, row).getContents().toString();
testDataProvider[row][col] = data;
}
}
book.close();
return testDataProvider;