工具类:
package com.cn.jll.utils.common;
import com.google.common.base.Strings;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.util.CellRangeAddress;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* @Descripation excel数据导出
* @Auther zqc
* @Date 2019/12/6 11:16
* @since 1.0
**/
public class ExcelExportUtil {
//表头
private String title;
//各个列的表头
private String[] heardList;
//各个列的元素key值
private String[] heardKey;
//需要填充的数据信息
private List<Map> data;
//字体大小
private int fontSize = 14;
//行高
private int rowHeight = 30;
//列宽
private int columWidth = 200;
//工作表
private String sheetName = "sheet1";
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String[] getHeardList() {
return heardList;
}
public void setHeardList(String[] heardList) {
this.heardList = heardList;
}
public String[] getHeardKey() {
return heardKey;
}
public void setHeardKey(String[] heardKey) {
this.heardKey = heardKey;
}
public List<Map> getData() {
return data;
}
public void setData(List<Map> data) {
this.data = data;
}
public int getFontSize() {
return fontSize;
}
public void setFontSize(int fontSize) {
this.fontSize = fontSize;
}
public int getRowHeight() {
return rowHeight;
}
public void setRowHeight(int rowHeight) {
this.rowHeight = r