我有使用JXL和Java从工作表中获取数据的代码,但在流程结束时,我需要从页面获取数据并写入工作表中的某个单元格。
//reading the worksheet
Workbook workbook = Workbook.getWorkbook(new File("d:/planilha.xls"));
//Indicate the opening of the first worksheet
Sheet sheet = workbook.getSheet(0);
//Count the rows
int linhas = sheet.getRows();
//Start a for loop to scan all rows in the already selected worksheet
for(int i = 1; i < linhas; i++){
//Referencing rows that have content
Cell nome_promocao = sheet.getCell(0, i);
Cell desc_promocao = sheet.getCell(1, i);
Cell tipo_promocao = sheet.getCell(2, i);
Cell dt_inicio = sheet.getCell(3, i);
Cell dt_fim = sheet.getCell(4, i);
Cell aparelho = sheet.getCell(5, i);
Cell idpromo = sheet.getCell(6, i);
//Taking the data from the worksheet
String linhanomepromocao = nome_promocao.getContents();
String linhadescpromocao = desc_promocao.getContents();
String linhatipopromocao = tipo_promocao.getContents();
String linhadtinicio= dt_inicio.getContents();
String linhadtfim = dt_fim.getContents();
String linhaaparelho = aparelho.getContents();
String linhaidpromo = idpromo.getContents();
//Other actions
//Get the id I need on the page and saving in a variable
String numberpromotion = driver.findElement(By.className("link")).getText();
//I need to record this number of the above variable in the corresponding cell (idpromo or linhaidpromo)
答案 0 :(得分:0)
这是否能解答您的问题?:
Label label = new Label(6, i, numberpromotion);
sheet.addCell(label);