using NPOI.SS.UserModel;
using System;

namespace DeviceRepairAndOptimization.Common.NpoiExtend
{
    public class StyleConst
    {
        private static StyleConst manager;
        public static StyleConst Instance
        {
            get
            {
                if (manager == null)
                    manager = new StyleConst();
                return manager;
            }
        }

        public ICellStyle HeadStyle(IWorkbook workbook)
        {
            ICellStyle style = workbook.CreateCellStyle();
            style.WrapText = true;//设置换行这个要先设置
            style.Alignment = HorizontalAlignment.Center;//居中
            style.VerticalAlignment = VerticalAlignment.Center;
            style.FillPattern = FillPattern.SolidForeground;
            style.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Grey25Percent.Index;
            return style;
        }

        public ICellStyle ContentStyle(IWorkbook workbook)
        {
            ICellStyle cellStyle = workbook.CreateCellStyle();
            cellStyle.Alignment = HorizontalAlignment.Center;//居中
            cellStyle.VerticalAlignment = VerticalAlignment.Center;//水平居中
            cellStyle.BorderLeft = BorderStyle.Thin;
            cellStyle.BorderTop = BorderStyle.Thin;
            cellStyle.BorderRight = BorderStyle.Thin;
            cellStyle.BorderBottom = BorderStyle.Thin;
            return cellStyle;
        }
    }
}
