创建用于添加表头的实体类
/**
* excel导出标题显示值
* @author Terisadeng
*
*/
public class KeyValue {
private String key;
private String value;
public String getKey() {
return key;
}
public KeyValue(){}
public KeyValue(String key, String value) {
super();
this.key = key;
this.value = value;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
定义生成文件名的方法
/**
*
* Description: 设置导出xls格式Excel文件的文件名 by Terisadeng
* Implement:
* @return
* @see
*/
public static String getFileName() {
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmm");
StringBuilder sb = new StringBuilder();
sb.append(sf.format(System.currentTimeMillis()));
sb.append(".xls");
return sb.toString();
}
/**
*
* Description: 设置导出xlsx格式Excel文件的文件名 by Teris