public IWorkbook Decorate(IWorkbook workbook, DecoratorContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            var attr = context.TypeDecoratorInfo.GetDecorateAttr <WrapTextAttribute>();

            if (attr == null)
            {
                return(workbook);
            }

            ISheet sheet = workbook.GetSheetAt(0);
            IRow   row;

            if (sheet.PhysicalNumberOfRows > 0)
            {
                for (int i = 0; i < sheet.PhysicalNumberOfRows; i++)
                {
                    row = sheet.GetRow(i);
                    for (int colIndex = 0; colIndex < row.PhysicalNumberOfCells; colIndex++)
                    {
                        row.GetCell(colIndex).CellStyle.WrapText = true;
                    }
                }
            }

            return(workbook);
        }
        public IWorkbook Decorate(IWorkbook workbook, DecoratorContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            var attr = (HeaderAttribute)context.TypeDecoratorInfo.TypeDecoratorAttrs.SingleOrDefault(a => a.GetType() == typeof(HeaderAttribute));

            if (attr == null)
            {
                return(workbook);
            }

            IRow       headerRow = workbook.GetSheetAt(0).GetRow(0);
            ICellStyle style     = workbook.CreateCellStyle();
            IFont      font      = workbook.CreateFont();

            font.FontName           = attr.FontName;
            font.Color              = (short)attr.Color.GetHashCode();
            font.FontHeightInPoints = (short)attr.FontSize;
            if (attr.IsBold)
            {
                font.Boldweight = short.MaxValue;
            }

            style.SetFont(font);

            for (int i = 0; i < headerRow.PhysicalNumberOfCells; i++)
            {
                headerRow.GetCell(i).CellStyle = style;
            }

            return(workbook);
        }
        private static void Decorate <T>()
            where T : class, new()
        {
            DecoratorContext context = new DecoratorContext()
            {
                TypeDecoratorInfo = TypeDecoratorInfoFactory.CreateInstance(typeof(T))
            };

            GetDecorators <T>().ForEach(d =>
            {
                Workbook = d.Decorate(Workbook, context);
            });
        }
        public IWorkbook Decorate(IWorkbook workbook, DecoratorContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            var    propertyDecoratorInfos = context.TypeDecoratorInfo.PropertyDecoratorInfos;
            ISheet sheet = workbook.GetSheetAt(0);

            foreach (var item in propertyDecoratorInfos)
            {
                if (item.DecoratorAttrs.SingleOrDefault(a => a.GetType() == typeof(MergeColsAttribute)) != null)
                {
                    InternalDecorate(sheet, item.ColIndex);
                }
            }

            return(workbook);
        }