如何使用JSR223或beanshell采样器在Jmeter中创建工作簿?

mlmc2os5  于 2023-01-13  发布在  Shell
关注(0)|答案(1)|浏览(170)

当我尝试在Jmeter中创建工作簿时出错。我正在使用“tika-app.jar”工作簿创建完成后,我想在Excel xlx文件中写入数据。
下面是我的JSR 223采样器:

我得到的错误响应如下:

有人能帮忙吗

xqnpmsa8

xqnpmsa81#

1.将tika-app-xxx.jar复制到JMeter安装的“lib”文件夹
1.重新启动JMeter以拾取.jar文件
1.切换到groovy language
1.您的代码应该可以开始工作,并且不会出现“找不到类”错误
如果您正在寻找有关如何填充Excel文件的“食谱”,请查看Busy Developers' Guide to HSSF and XSSF Features
以防万一上面指南中的一段代码:

Workbook wb = new HSSFWorkbook();
//Workbook wb = new XSSFWorkbook();
CreationHelper createHelper = wb.getCreationHelper();
Sheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
Row row = sheet.createRow(0);
// Create a cell and put a value in it.
Cell cell = row.createCell(0);
cell.setCellValue(1);
// Or do it on one line.
row.createCell(1).setCellValue(1.2);
row.createCell(2).setCellValue(
createHelper.createRichTextString("This is a string"));
row.createCell(3).setCellValue(true);
// Write the output to a file
try (OutputStream fileOut = new FileOutputStream("workbook.xls")) {
    wb.write(fileOut);
}

相关问题