Beispiel #1
0
        internal IFont CreateFont(RowStyle rowStyle)
        {
            IColor fontColor = this.CreateColor(rowStyle.FontColor);
            IFont  font;

            switch (this.ExcelVersion)
            {
            case ExcelVersion.XLS:
            {
                XLSStrategyStyle xLSStrategyStyle = new XLSStrategyStyle(this.ExcelXls);
                font = xLSStrategyStyle.GetFont(rowStyle.FontSize, rowStyle.FontName, fontColor);
                break;
            }

            case ExcelVersion.XLSX:
            {
                XLSXStrategyStyle xLSXStrategyStyle = new XLSXStrategyStyle(this.ExcelXlsx);
                font = xLSXStrategyStyle.GetFont(rowStyle.FontSize, rowStyle.FontName, fontColor);
                break;
            }

            default:
                throw new Exception(ErrorMessage.Excel_BadVersion);
            }
            return(font);
        }
Beispiel #2
0
        internal ICellStyle CreateCellStyle(RowStyle rowStyle)
        {
            IColor     borderColor = this.CreateColor(rowStyle.BorderColor);
            IColor     backColor   = this.CreateColor(rowStyle.BackColor);
            IFont      font        = this.CreateFont(rowStyle);
            ICellStyle cellStyle;

            switch (this.ExcelVersion)
            {
            case ExcelVersion.XLS:
            {
                XLSStrategyStyle xLSStrategyStyle = new XLSStrategyStyle(this.ExcelXls);
                cellStyle = xLSStrategyStyle.GetCellStyle(backColor, borderColor, font);
                break;
            }

            case ExcelVersion.XLSX:
            {
                XLSXStrategyStyle xLSXStrategyStyle = new XLSXStrategyStyle(this.ExcelXlsx);
                cellStyle = xLSXStrategyStyle.GetCellStyle(backColor, borderColor, font);
                break;
            }

            default:
                throw new Exception(ErrorMessage.Excel_BadVersion);
            }
            return(cellStyle);
        }