Katalon Studio-如何使用不同的循环写入Excel的不同列

问题描述

我的代码如下

@Keyword 
public void demoKey(String variable1,int index1) throws IOException{

    FileInputStream fis = new FileInputStream("C:\\Selenium\\PortalRedesigNLogic.xlsx");
    XSSFWorkbook workbook = new XSSFWorkbook(fis);
    XSSFSheet sheet = workbook.getSheet("Sheet1");
    Row row = sheet.createRow(index1);
    Cell cell = row.createCell(0);
    cell.setCellType(cell.CELL_TYPE_STRING);
    cell.setCellValue(variable1);
//  sheet.getRow(index1);
//  row.getCell(1);
    FileOutputStream fos = new FileOutputStream("C:\\Selenium\\PortalRedesigNLogic.xlsx");
    workbook.write(fos);
    fos.close();
}

这对于一列写得很好,但是我在CALL测试用例中有另一个循环 我希望这个关键字可以遍历并写入第二列 这样我就可以比较两个循环的数据 第一列和第二列。

我的测试用例如下:

 CustomKeywords.'common.WriteToExcelrow1.demoKey'(x,sitedropdownloop)

x(将要写入的内部文本),sitedropdownloop是循环名称

在CALL测试用例中,我也有

CustomKeywords.'common.WriteToExcelrow1.demoKey'(y,oldsitedropdownloop)

y(是将在第二列中编写的内部文本),而oldsitedropdownloop是另一个循环的名称。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...