尝试使用 Jmeter 创建xlsx文件时出现错误。实际上,我已经尝试使用HSSF(对于 .xls)并且效果很好。但是当我尝试使用xlsx更改它时,我遇到了错误。我已经在 jmeter lib文件上复制了poi和poi-ooxml的 jar文件。这是我的简单脚本:
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;
import java.lang.String;
import java.lang.Object;
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Sample sheet");
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue("HENCIN");
try {
FileOutputStream out = new FileOutputStream(new File("D:\\Jmeter\\testhencin.xlsx"));
workbook.write(out);
out.close();
System.out.println("Excel written successfully..");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
实际上,当我试图找到错误时,问题来自这一行:
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Sample sheet");
请有人帮我弄清楚。它适用于HSSF,但在XSSF上不起作用。我收到错误:响应代码:500
Response message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval org/apache/xmlbeans/XmlObject