- Excel测试记录文件模板
设计Excel的数据结构
- 下载jxl.jar
- Java 代码编码
通过将java代码打包成jar,然后放入Jmeter目录下进行引用
代码如下:
package com.sishi;
import jxl.Workbook;
import jxl.format.Colour;
import jxl.write.*;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class JmeterResult {
public String CreateResultFile(String fileName){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd-HH_mm_ss");
Date datetime = new Date();
String folderPath = fileName.substring(0, fileName.lastIndexOf("\\"));
WritableWorkbook wb = null;
String filePath = "";
try{
String timestamp = sdf.format(datetime);
File initialPath = new File(folderPath);
if (!initialPath.exists()) {
initialPath.mkdirs();
}
filePath = fileName + "_Test_result" + "_" + timestamp + ".xls";
File output = new File(filePath);
if (!output.isFile()) {