jmeter 在beanshell中创建Excel文件
上脚本
import jxl.write.WritableWorkbook;import jxl.write.WritableSheet;import jxl.write.Label;import jxl.Workbook;//开始写入excel,创建模型文件头String[] titleA = {\"姓名\",\"手机号码\"};//创建Excel文件,B库CD表文件File fileA = new File(\"D:/jmeter/jmx/导入/import-tmp.xlsx\");if(fileA.exists()){//如果文件存在就删除fileA.delete();}fileA.createNewFile();//创建工作簿WritableWorkbook workbookA = Workbook.createWorkbook(fileA);//创建sheetWritableSheet sheetA = workbookA.createSheet(\"sheet1\", 0);Label labelA = null;//设置列名for (int i = 0; i < titleA.length; i++) {labelA = new Label(i,0,titleA[i]);sheetA.addCell(labelA);}//获取数据源for (int i = 1; i < 4; i++) {labelA = new Label(0,i,\"name\"+i);sheetA.addCell(labelA);labelA = new Label(1,i,\"19\"+i+\"${__time(ddHHmmss,)}\");sheetA.addCell(labelA);}workbookA.write();workbookA.close();