package com.vci.starter.poi.bo; import java.util.List; /** * 写入到excel里的数据 * @author weidy */ public class WriteExcelData { //默认的属性 /** * 行号,从0开始 */ private int row; /** * 列号,从0开始 */ private int col; /** * 读取或者写入的值对象 */ private Object obj; //合并和样式 /** * 是否需要合并单元格 */ private boolean merged = false; /** * 合并行的目标行号,从0开始 */ private int rowTo; /** * 合并列的目标列号,从0开始 */ private int colTo; /** * 是否拷贝样式 */ private boolean copyStyle = false; /** * 拷贝样式的行 */ private int copyStyleRow; /** * 拷贝样式的列 */ private int copyStyleCol; /** * 是否居中 */ private boolean center; //公式 /** * 是否为公式,公式的值设置到obj属性上 */ private boolean formula = false; //名称管理器 /** * 名称管理器,级联选择的时候定义,名称为obj属性,范围是row,rowto,col,colto */ private boolean nameRefer = false; //数据有效性 /** * 数据有效性,公式是Obj属性,范围是row,rowto,col,colto */ private boolean validation = false; /** * 有效性序列的值 */ private List validationDataList; /** * 有效性校验失败的时候的提示信息,如果设置就表示会显示错误 */ private String validationErrorMsg ; /** * 字体颜色 */ private String fontColor; /** * 时间格式 */ private String dateFormat; /** * 只读 */ private boolean readOnly; /** * 单元格宽度,差不多是html上表格宽度除以10 */ private Integer width; public String getFontColor() { return fontColor; } public void setFontColor(String fontColor) { this.fontColor = fontColor; } public List getValidationDataList() { return validationDataList; } public void setValidationDataList(List validationDataList) { this.validationDataList = validationDataList; } /** * 默认的构造方法 */ public WriteExcelData(){ } /** * 构造方法 * @param row 行 * @param col 列 * @param obj 值 */ public WriteExcelData(int row, int col, Object obj){ this.row = row; this.col = col; this.obj = obj; } /** * 构造方法-是否居中 * @param row 行 * @param col 列 * @param obj 值 */ public WriteExcelData(int row, int col, boolean center, Object obj){ this.row = row; this.col = col; this.center = center; this.obj = obj; } /** * 构造方法-合并,居中参数 * @param row 行 * @param rowTo 合并行 * @param merged 是否合并单元格 * @param center 是否居中 * @param col 列 * @param obj 值 */ public WriteExcelData(int row,int rowTo,boolean merged,boolean center, int col, Object obj){ this.row = row; this.rowTo = rowTo; this.merged = merged; this.center = center; this.col = col; this.obj = obj; } /** * 写公式 * @param row 行号 从0 开始 * @param col 列号从0开始 * @param foumula 公式的值 */ public void writeFormula(int row,int col, String foumula){ this.row = row; this.col = col; this.obj = foumula; this.formula = true; } /** * 写名称管理器 * @param row 行号 * @param col 列号 * @param rowTo 结束行的行号 * @param colTo 结束列的列号 * @param name 名称管理器的名称 */ public void writeNameRefer(int row,int col, int rowTo,int colTo,String name){ this.row = row; this.col = col; this.obj = name; this.nameRefer = true; this.rowTo = rowTo; this.colTo = colTo; } /** * 写入下拉列表的值 * @param comboBoxData 下拉菜单的值 * @param row 行号 * @param col 列号 * @param rowTo 结束行号 * @param colTo 结束列号 */ public void writeComboBox( List comboBoxData,int row,int col,int rowTo,int colTo){ writeComboBox(comboBoxData,null,row,col,rowTo,colTo); } /** * 写入下拉列表的值 * @param comboBoxData 下拉菜单的值 * @param errorMsg 错误的提示信息 * @param row 行号 * @param col 列号 * @param rowTo 结束行号 * @param colTo 结束列号 */ public void writeComboBox( List comboBoxData,String errorMsg,int row,int col,int rowTo,int colTo){ this.validationDataList = comboBoxData; this.validation= true; this.validationErrorMsg = errorMsg; this.row = row; this.col = col; this.rowTo = rowTo; this.colTo = colTo; } /** * 有效性序列引用其他的 * @param referFormula 引用的公式 * @param row 行号 * @param col 列号 * @param rowTo 结束行号 * @param colTo 结束列号 */ public void writeUseRefer(String referFormula,int row,int col,int rowTo,int colTo){ writeUseRefer(referFormula,null,row,col,rowTo,colTo); } /** * 有效性序列引用其他的 * @param referFormula 引用的公式 * @param errorMsg 错误的提示信息 * @param row 行号 * @param col 列号 * @param rowTo 结束行号 * @param colTo 结束列号 */ public void writeUseRefer(String referFormula,String errorMsg,int row,int col,int rowTo,int colTo){ this.validation= true; this.obj = referFormula; this.validationErrorMsg = errorMsg; this.row = row; this.col = col; this.rowTo = rowTo; this.colTo = colTo; } public boolean isReadOnly() { return readOnly; } public void setReadOnly(boolean readOnly) { this.readOnly = readOnly; } public int getRow() { return row; } public void setRow(int row) { this.row = row; } public int getCol() { return col; } public void setCol(int col) { this.col = col; } public Object getObj() { return obj; } public void setObj(Object obj) { this.obj = obj; } public boolean isMerged() { return merged; } public void setMerged(boolean merged) { this.merged = merged; } public int getRowTo() { return rowTo; } public void setRowTo(int rowTo) { this.rowTo = rowTo; } public int getColTo() { return colTo; } public void setColTo(int colTo) { this.colTo = colTo; } public boolean isCopyStyle() { return copyStyle; } public void setCopyStyle(boolean copyStyle) { this.copyStyle = copyStyle; } public int getCopyStyleRow() { return copyStyleRow; } public void setCopyStyleRow(int copyStyleRow) { this.copyStyleRow = copyStyleRow; } public int getCopyStyleCol() { return copyStyleCol; } public void setCopyStyleCol(int copyStyleCol) { this.copyStyleCol = copyStyleCol; } public boolean isCenter() { return center; } public void setCenter(boolean center) { this.center = center; } public boolean isFormula() { return formula; } public void setFormula(boolean formula) { this.formula = formula; } public boolean isNameRefer() { return nameRefer; } public void setNameRefer(boolean nameRefer) { this.nameRefer = nameRefer; } public boolean isValidation() { return validation; } public void setValidation(boolean validation) { this.validation = validation; } public String getValidationErrorMsg() { return validationErrorMsg; } public void setValidationErrorMsg(String validationErrorMsg) { this.validationErrorMsg = validationErrorMsg; } public String getDateFormat() { return dateFormat; } public void setDateFormat(String dateFormat) { this.dateFormat = dateFormat; } public Integer getWidth() { return width; } public void setWidth(Integer width) { this.width = width; } @Override public String toString() { return "WriteExcelData{" + "row=" + row + ", col=" + col + ", obj=" + obj + ", merged=" + merged + ", rowTo=" + rowTo + ", colTo=" + colTo + ", copyStyle=" + copyStyle + ", copyStyleRow=" + copyStyleRow + ", copyStyleCol=" + copyStyleCol + ", center=" + center + ", formula=" + formula + ", nameRefer=" + nameRefer + ", validation=" + validation + ", validationDataList=" + validationDataList + ", validationErrorMsg='" + validationErrorMsg + '\'' + ", fontColor='" + fontColor + '\'' + ", dateFormat='" + dateFormat + '\'' + ", readOnly=" + readOnly + '}'; } }