Пример #1
0
 public RptAutoGrModel InitModel(RptAutoGrModel model)
 {
     model.CurrentLogin      = CurrentUser;
     model.CurrentPageAccess = CurrentPageAccess;
     model.MainMenu          = _mainMenu;
     return(model);
 }
Пример #2
0
        public ActionResult Index(RptAutoGrModel model)
        {
            model = InitModel(model);

            var data = _autoGrBLL.GetAutoGR(new RptAutoGrInput()
            {
                PeriodEnd   = model.PeriodEnd,
                PeriodStart = model.PeriodStart
            });

            model.Details = Mapper.Map <List <RptAutoGrItem> >(data);



            return(View(model));
        }
Пример #3
0
        public void ExportToExcel(RptAutoGrModel model)
        {
            string pathFile = "";

            pathFile = CreateXlsDashboard(model);

            var newFile = new FileInfo(pathFile);

            var fileName = Path.GetFileName(pathFile);

            string attachment = string.Format("attachment; filename={0}", fileName);

            Response.Clear();
            Response.AddHeader("content-disposition", attachment);
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            Response.WriteFile(newFile.FullName);
            Response.Flush();
            newFile.Delete();
            Response.End();
        }
Пример #4
0
        private string CreateXlsDashboard(RptAutoGrModel model)
        {
            //get data
            var data = _autoGrBLL.GetAutoGR(new RptAutoGrInput()
            {
                PeriodEnd   = model.PeriodEnd,
                PeriodStart = model.PeriodStart
            });

            var listData = Mapper.Map <List <RptAutoGrItem> >(data);

            var slDocument = new SLDocument();

            //title
            slDocument.SetCellValue(1, 1, "Auto GR Report");
            slDocument.MergeWorksheetCells(1, 1, 1, 9);
            //create style
            SLStyle valueStyle = slDocument.CreateStyle();

            valueStyle.SetHorizontalAlignment(HorizontalAlignmentValues.Center);
            valueStyle.Font.Bold     = true;
            valueStyle.Font.FontSize = 18;
            slDocument.SetCellStyle(1, 1, valueStyle);

            //create header
            slDocument = CreateHeaderExcelDashboard(slDocument);

            //create data
            slDocument = CreateDataExcelDashboard(slDocument, listData);

            var fileName = "Auto_GR_Report" + DateTime.Now.ToString("_yyyyMMddHHmmss") + ".xlsx";
            var path     = Path.Combine(Server.MapPath(Constans.UploadPath), fileName);

            slDocument.SaveAs(path);

            return(path);
        }