package com.yanzuoguang.excel;

import io.swagger.annotations.ApiModelProperty;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;

/**
 * 单元格
 *
 * @author 颜佐光
 */
public class ExcelDefineCell {
    /**
     * 第几列
     */
    @ApiModelProperty(notes = "第几列")
    private short column;
    /**
     * 横合并
     */
    @ApiModelProperty(notes = "横合并")
    private short widthSize;
    /**
     * 竖合并
     */
    @ApiModelProperty(notes = "竖合并")
    private short heightSize;
    /**
     * 对其
     */
    @ApiModelProperty(notes = "左右对其:0-居中,1-左对其,2-右对齐")
    private int alignment;
    /**
     * 对其
     */
    @ApiModelProperty(notes = "上下对其:0-居中,1-上对其,2-下对齐")
    private int verticalAlignment;
    /**
     * 文字内容
     */
    @ApiModelProperty(notes = "文字内容")
    private Object value;
    /**
     * 公式,如:SUM(C2:C3),或者SUM({columnName}),公式优先.不能SUM(columnA/columnB)。
     * 数据列={columnName_COL},指的是数据列名称对应转换的Excel列名,
     * 当前行={rowIndex},
     * 数据开始行={startDataRowIndex},
     * 数据结束行={endDataRowIndex},
     * 数据所有单元格={columnName}={columnName_COL}{startDataRowIndex}:{columnName_COL}{endDataRowIndex}
     */
    @ApiModelProperty(notes = " 公式,如:SUM(C2:C3),或者SUM({columnName}),公式优先.不能SUM(columnA/columnB)。" +
            "数据列={columnName_COL},指的是数据列名称对应转换的Excel列名," +
            "当前行={rowIndex}," +
            "数据开始行={startDataRowIndex}," +
            "数据结束行={endDataRowIndex}" +
            "数据所有单元格={columnName}={columnName_COL}{startDataRowIndex}:{columnName_COL}{endDataRowIndex}")
    private String formula;
    /**
     * 上边框
     */
    @ApiModelProperty(notes = "上边框")
    private boolean topBorder = true;
    /**
     * 下边框
     */
    @ApiModelProperty(notes = "下边框")
    private boolean bottomBorder = true;
    /**
     * 左边框
     */
    @ApiModelProperty(notes = "左边框")
    private boolean leftBorder = true;
    /**
     * 下边框
     */
    @ApiModelProperty(notes = "下边框")
    private boolean rightBorder = true;
    /**
     * 当前单元格样式
     */
    CellStyle cellStyle;
    /**
     * 单元格
     */
    Cell cell;

    public ExcelDefineCell() {
    }

    public ExcelDefineCell(short column, String formula) {
        this.column = column;
        this.formula = formula;
    }

    public ExcelDefineCell(short column, Object value, String formula) {
        this.column = column;
        this.value = value;
        this.formula = formula;
    }

    public short getColumn() {
        return column;
    }

    public void setColumn(short column) {
        this.column = column;
    }

    public short getWidthSize() {
        return (short) Math.max(1, widthSize);
    }

    public void setWidthSize(short widthSize) {
        this.widthSize = widthSize;
    }

    public short getHeightSize() {
        return (short) Math.max(1, heightSize);
    }

    public void setHeightSize(short heightSize) {
        this.heightSize = heightSize;
    }

    public int getAlignment() {
        return alignment;
    }

    public void setAlignment(int alignment) {
        this.alignment = alignment;
    }

    public int getVerticalAlignment() {
        return verticalAlignment;
    }

    public void setVerticalAlignment(int verticalAlignment) {
        this.verticalAlignment = verticalAlignment;
    }

    public Object getValue() {
        return value;
    }

    public void setValue(Object value) {
        this.value = value;
    }

    public String getFormula() {
        return formula;
    }

    public void setFormula(String formula) {
        this.formula = formula;
    }

    public boolean isTopBorder() {
        return topBorder;
    }

    public void setTopBorder(boolean topBorder) {
        this.topBorder = topBorder;
    }

    public boolean isBottomBorder() {
        return bottomBorder;
    }

    public void setBottomBorder(boolean bottomBorder) {
        this.bottomBorder = bottomBorder;
    }

    public boolean isLeftBorder() {
        return leftBorder;
    }

    public void setLeftBorder(boolean leftBorder) {
        this.leftBorder = leftBorder;
    }

    public boolean isRightBorder() {
        return rightBorder;
    }

    public void setRightBorder(boolean rightBorder) {
        this.rightBorder = rightBorder;
    }
}