package xyz.wbsite.frame.excel.style;

import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Workbook;

/**
 * Created on 2015/1/29.
 *
 * @author
 * @since 2.0.0
 */
public class BaseCellStyle {
    /**
     * 样式
     */
    protected CellStyle style;

    public BaseCellStyle(Workbook workbook) {
        style = workbook.createCellStyle();
        style.setFillPattern(CellStyle.NO_FILL);
        //下边框
        style.setBorderBottom(CellStyle.SOLID_FOREGROUND);
        //下边框颜色
        style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
        //左边框
        style.setBorderLeft(CellStyle.SOLID_FOREGROUND);
        //左边框颜色
        style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
        //右边框
        style.setBorderRight(CellStyle.SOLID_FOREGROUND);
        //右边框颜色
        style.setRightBorderColor(IndexedColors.BLACK.getIndex());
        //上边框
        style.setBorderTop(CellStyle.SOLID_FOREGROUND);
        //上边框颜色
        style.setTopBorderColor(IndexedColors.BLACK.getIndex());

        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);      //上下居中
        style.setBorderBottom(CellStyle.SOLID_FOREGROUND);          //下边框
        style.setBottomBorderColor(IndexedColors.BLACK.getIndex()); //下边框颜色
        style.setBorderLeft(CellStyle.SOLID_FOREGROUND);            //左边框
        style.setLeftBorderColor(IndexedColors.BLACK.getIndex());   //左边框颜色
        style.setBorderRight(CellStyle.SOLID_FOREGROUND);           //右边框
        style.setRightBorderColor(IndexedColors.BLACK.getIndex());  //右边框颜色
        style.setBorderTop(CellStyle.SOLID_FOREGROUND);             //上边框
        style.setTopBorderColor(IndexedColors.BLACK.getIndex());    //上边框颜色
    }

    public CellStyle getStyle() {
        return style;
    }

    public void setStyle(CellStyle style) {
        this.style = style;
    }
}
