package cn.report.excel.easyexcel.custom.base;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.ObjectUtils;
import cn.report.excel.easyexcel.api.write.handler.CellWriteHandler;
import cn.report.excel.easyexcel.api.write.handler.SheetWriteHandler;
import cn.report.excel.easyexcel.api.write.style.HorizontalCellStyleStrategy;
import cn.report.excel.easyexcel.custom.SamCellMergeStrategy;


/**导出相关工具类：
 * 定义需要的一些数据字段。
 */
public class EasyExcelParam
{
	/**
	 * 对于非空字典判空条件
	 */
	public boolean isValid() {
		return ObjectUtils.allNotNull(fileName, data, response, dataModelClazz);
	}
	
	public EasyExcelParam(
			String streamType,String fileName, String sheetName, 
			Boolean needHead,String[] header, 
			SheetWriteHandler headerStyle,int headerNum,
			CellWriteHandler headerLine,
			HorizontalCellStyleStrategy cellStyle,
			List<?> data, 
			Class<?> dataModelClazz, 
			HttpServletResponse response) 
	{
		this.streamType = streamType;//写入本地文件（fileName含路径） 或 网络流文件
		this.fileName = fileName;//含有路径的文件名
		this.sheetName = sheetName;//sheet名字
		this.header = header;
		this.headerStyle = headerStyle;
		this.needHead = needHead;
		this.headerNum = headerNum;
		this.headerLine = headerLine;

		this.cellStyle = cellStyle;
		this.data = data;
		this.dataModelClazz = dataModelClazz;
		this.response = response;
	}

	public EasyExcelParam(
			String streamType,String fileName, String sheetName, 
			Boolean needHead,String[] header, 
			List<?> data, 
			Class<?> dataModelClazz, 
			HttpServletResponse response
	){
		this.streamType = streamType;//写入本地文件（fileName含路径） 或 网络流文件
		this.fileName = fileName;//含有路径的文件名
		this.sheetName = sheetName;//sheet名字
		this.header = header;
		this.needHead = needHead;
		this.data = data;
		this.dataModelClazz = dataModelClazz;
		this.response = response;
	}
	public EasyExcelParam(
			String fileName,
			Boolean needHead,String[] header, 
			List<?> data, 
			Class<?> dataModelClazz, 
			HttpServletResponse response
	){
		this.fileName = fileName;//含有路径的文件名
		this.header = header;
		this.needHead = needHead;
		this.data = data;
		this.dataModelClazz = dataModelClazz;
		this.response = response;
	}
	
	//sheet编号
	private Integer sheetNo = 0;

	/**将文件输出到浏览器(导出)Browse 或 本地文件File*/
	private String streamType = "Browse";

	/**文件名 */
	private String fileName;
	/**sheet名*/
	private String sheetName;

	/**是否需要表头*/
	private Boolean needHead;
	private String[] header;//表头
	private SheetWriteHandler headerStyle;//表头样式
	private int headerNum = 1;//表头行数
	private CellWriteHandler headerLine;//绘制斜线表头

	//表头与内容样式
	private HorizontalCellStyleStrategy cellStyle;

	//密码
	private String password;
	//水印
	private SheetWriteHandler waterMark;
	//合并
	private SamCellMergeStrategy cellMerge;

	/**导出数据 */
	private List<?> data;
	/**数据模型类型*/
	private Class<?> dataModelClazz;
	/** 响应 */
	private HttpServletResponse response;
	/**单元格样式*/
	private ExcelStyleConfig styleConfig;


	public void setStyleConfig(ExcelStyleConfig styleConfig) {
		this.styleConfig = styleConfig;
	}

	public Integer getSheetNo() {
		return sheetNo;
	}

	public void setSheetNo(Integer sheetNo) {
		this.sheetNo = sheetNo;
	}

	public String getStreamType() {
		return streamType;
	}

	public void setStreamType(String streamType) {
		this.streamType = streamType;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getSheetName() {
		return sheetName;
	}

	public void setSheetName(String sheetName) {
		this.sheetName = sheetName;
	}

	public Boolean getNeedHead() {
		return needHead;
	}

	public void setNeedHead(Boolean needHead) {
		this.needHead = needHead;
	}

	public String[] getHeader() {
		return header;
	}

	public void setHeader(String[] header) {
		this.header = header;
	}

	public SheetWriteHandler getHeaderStyle() {
		return headerStyle;
	}

	public void setHeaderStyle(SheetWriteHandler headerStyle) {
		this.headerStyle = headerStyle;
	}

	public int getHeaderNum() {
		return headerNum;
	}

	public void setHeaderNum(int headerNum) {
		this.headerNum = headerNum;
	}

	public CellWriteHandler getHeaderLine() {
		return headerLine;
	}

	public void setHeaderLine(CellWriteHandler headerLine) {
		this.headerLine = headerLine;
	}

	public HorizontalCellStyleStrategy getCellStyle() {
		return cellStyle;
	}

	public void setCellStyle(HorizontalCellStyleStrategy cellStyle) {
		this.cellStyle = cellStyle;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public SheetWriteHandler getWaterMark() {
		return waterMark;
	}

	public void setWaterMark(SheetWriteHandler waterMark) {
		this.waterMark = waterMark;
	}

	public SamCellMergeStrategy getCellMerge() {
		return cellMerge;
	}

	public void setCellMerge(SamCellMergeStrategy cellMerge) {
		this.cellMerge = cellMerge;
	}

	public List<?> getData() {
		return data;
	}

	public void setData(List<?> data) {
		this.data = data;
	}

	public Class<?> getDataModelClazz() {
		return dataModelClazz;
	}

	public void setDataModelClazz(Class<?> dataModelClazz) {
		this.dataModelClazz = dataModelClazz;
	}

	public HttpServletResponse getResponse() {
		return response;
	}

	public void setResponse(HttpServletResponse response) {
		this.response = response;
	}

	public ExcelStyleConfig getStyleConfig() {
		return styleConfig;
	}

}
