示例#1
0
        public MemoryStream Get(T[] rows, string language)
        {
            CultureProvider.Set(language);

            var properties = rows.GetType().GetElementType().GetProperties();

            var stream = new MemoryStream();

            using (var pck = new ExcelPackage())
            {
                var ws = pck.Workbook.Worksheets.Add(Pages.Applications);
                ws.Cells.Style.Font.Name = ExcelConstants.DefaultFontName;
                ws.Cells.Style.Font.Size = ExcelConstants.DefaultFontSize;

                DrawHeader(properties, ws);

                DrawRows(rows, properties, ws);

                for (var iCol = 1; iCol <= properties.Length; iCol++)
                {
                    ws.Column(iCol).AutoFit();
                }

                pck.SaveAs(stream);
            }

            stream.Position = 0;

            return(stream);
        }
示例#2
0
        public MemoryStream Get(long clientId, string language)
        {
            CultureProvider.Set(language);

            var client = _clients.Get(clientId);

            var balance = _balance.GetBalance(clientId);

            var calculations = _calculations.GetByClient(clientId);

            var history = _balance.GetHistory(clientId).Where(x => !x.IsCalculation).ToArray();

            return(Get(client, balance, calculations, history));
        }
示例#3
0
        internal MemoryStream Get(CalculationListCollection data, string language)
        {
            CultureProvider.Set(language);

            var stream = new MemoryStream();

            using (var pck = new ExcelPackage())
            {
                var ws = pck.Workbook.Worksheets.Add(Pages.Applications);
                ws.Cells.Style.Font.Name           = ExcelConstants.DefaultFontName;
                ws.Cells.Style.Font.Size           = ExcelConstants.DefaultFontSize;
                ws.Cells.Style.Numberformat.Format = "0.00";

                var count = DrawHeader(ws);

                var iRow = 2;
                for (int index = 0; index < data.Groups.Length; index++)
                {
                    var group = data.Groups[index];
                    var awb   = HttpUtility.HtmlDecode(((dynamic)@group.value).text);

                    DrawAwb(awb, ws, iRow++, count);

                    foreach (var item in group.items)
                    {
                        ws.Row(iRow).Height = ExcelConstants.DefaultRowHeight;
                        DrawRow(ws, item, iRow++);
                    }
                    ws.Row(iRow).Height = ExcelConstants.DefaultRowHeight;
                    DrawGroupTotal(ws, group, iRow++);

                    iRow = DrawInfo(ws, data.Info[index], iRow, count);
                }

                for (int j = 1; j <= count; j++)
                {
                    ws.Column(j).AutoFit();
                    for (int i = 1; i < iRow; i++)
                    {
                        ws.Cells[i, j].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.Gray);
                    }
                }

                pck.SaveAs(stream);
            }

            stream.Position = 0;

            return(stream);
        }
示例#4
0
 public void OnAuthorization(AuthorizationContext filterContext)
 {
     CultureProvider.Set(_getLanguage);
 }