简体   繁体   English

使用JXL和Java在现有工作表中写入数据

[英]Writing data in an existing worksheet using JXL and Java

I have the code to get data from the worksheet using JXL and Java, but at the end of the process I need to get a data from the page and write to a certain cell in the worksheet. 我有使用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)

图片

Does this provide answer to your question?: 这是否可以回答您的问题?:

Label label = new Label(6, i, numberpromotion);
sheet.addCell(label);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM