private void GenerateExcelBody(ExcelWorksheet excelWorksheet, ExcelSheetAttribute excelSheetAttribute, Dictionary <PropertyInfo, ExcelColumnAttribute> propertyDictionary)
        {
            TModel[]       modelArray        = Model.ToArray();
            PropertyInfo[] propertyInfoArray = propertyDictionary.Select(pd => pd.Key).ToArray();

            for (int row = 2; row <= modelArray.Length + 1; row++)
            {
                TModel currentModel = modelArray[row - 2];
                for (int col = 1; col <= propertyInfoArray.Length; col++)
                {
                    PropertyInfo         currentPropertyInfo  = propertyInfoArray[col - 1];
                    ExcelColumnAttribute excelColumnAttribute = propertyDictionary[currentPropertyInfo];
                    ExcelRange           currentCell          = excelWorksheet.Cells[row, col];
                    var displayFormatAttribute = currentPropertyInfo.GetCustomAttribute <DisplayFormatAttribute>();
                    if (displayFormatAttribute != null && typeof(IFormattable).IsAssignableFrom(currentPropertyInfo.PropertyType))
                    {
                        currentCell.Value = ((IFormattable)currentPropertyInfo.GetValue(currentModel)).ToString(displayFormatAttribute.DataFormatString, CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        currentCell.Value = currentPropertyInfo.GetValue(currentModel);
                    }
                }

                excelWorksheet.Row(row).Height = excelSheetAttribute.RowHeight;
            }
        }
        private void FormatExcelSheet(ExcelWorksheet excelWorksheet, ExcelSheetAttribute excelSheetAttribute, Dictionary <PropertyInfo, ExcelColumnAttribute> propertyDictionary)
        {
            PropertyInfo[] propertyInfoArray = propertyDictionary.Select(pd => pd.Key).ToArray();

            excelWorksheet.Cells.AutoFitColumns();

            for (int col = 1; col <= propertyInfoArray.Length; col++)
            {
                PropertyInfo         currentPropertyInfo  = propertyInfoArray[col - 1];
                ExcelColumnAttribute excelColumnAttribute = propertyDictionary[currentPropertyInfo];
                ExcelColumn          currentExcelColumn   = excelWorksheet.Column(col);
                currentExcelColumn.Style.Numberformat.Format = excelColumnAttribute.Format;
                currentExcelColumn.Style.QuotePrefix         = excelColumnAttribute.Quote;
                currentExcelColumn.Style.VerticalAlignment   = ExcelVerticalAlignment.Center;
                currentExcelColumn.Style.HorizontalAlignment = excelColumnAttribute.IsCenter ? ExcelHorizontalAlignment.Center : ExcelHorizontalAlignment.General;
                currentExcelColumn.Width += 3;
            }

            excelWorksheet.Row(1).Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
            excelWorksheet.Row(1).Style.Font.Bold           = true;
        }