Hi all,
maybe someone can help me with the following problem:
I want to write back into an Excel 2 times, first time i let Katalon read out the E-Mail of another Excelfile and when the Step in the Webapplication with pasting in the Mail, I let write back the Mail into another Excel. The second Time I want to write a “Done” in the next row (near to the Mail written in before) after all steps has been made.
I have the Problem that it’s just writing back a Done back into the Excel 1 time. Normally it should write back 14 Mail addresses and 14 “Dones”.
The Code for first time Writing back:
public class WriteExcel {
@Keyword
public void demoKey(String name) throws IOException{
FileInputStream fis = new FileInputStream("D:\\Demo\\Demo.xlsx");
XSSFWorkbook workbook = new XSSFWorkbook(fis);
XSSFSheet sheet = workbook.getSheet("Sheet1");
int rowCount = sheet.getLastRowNum()-sheet.getFirstRowNum();
Row row = sheet.createRow(rowCount+1);
Cell cell = row.createCell(1);
cell.setCellType(cell.CELL_TYPE_STRING);
cell.setCellValue(name);
FileOutputStream fos = new FileOutputStream("D:\\Demo\\Demo.xlsx");
workbook.write(fos);
fos.close();
}
}
Method in Test Case:
String result1 = findTestData(‘UserImport/TestExcel’).getValue(5, rowNum)
CustomKeywords.‘writeBackIntoTheExcel.WriteExcel2.demoKey’(result1)
Code second time writing back:
public class WriteExcel {
@Keyword
public void demoKey(String name) throws IOException{
FileInputStream fis = new FileInputStream("D:\\Demo\\Demo.xlsx");
XSSFWorkbook workbook = new XSSFWorkbook(fis);
XSSFSheet sheet = workbook.getSheet("Sheet1");
int rowCount = sheet.getLastRowNum()-sheet.getFirstRowNum();
Row row = sheet.createRow(rowCount+1);
Cell cell = row.createCell(2);
cell.setCellType(cell.CELL_TYPE_STRING);
cell.setCellValue(name);
FileOutputStream fos = new FileOutputStream("D:\\Demo\\Demo.xlsx");
workbook.write(fos);
fos.close();
}
}
Method in Test Case:
String result = ‘Done’
CustomKeywords.‘writeBackIntoTheExcel.WriteExcel.demoKey’(result)
Thanks a lot in forward