Пример #1
0
        public ActionResult CreateExcel()
        {
            var config = GetConfig();

            var report = new DevOpsReport(config);

            report.ExecEstimateReport(GetEstimateFile());

            var excel = new ExcelReport();

            excel.AddList(report.TaskEstimateReport, new Dictionary <string, string>());

            var bytes = excel.GetXlsFile();

            var key = $"Execl{Guid.NewGuid().ToString()}";

            TempData[key] = new TmpFile
            {
                FileName = "Оценка задач.xlsx",
                Content  = bytes
            };

            return(new JsonNetResult
            {
                Data = new
                {
                    key = key
                }
            });
        }
Пример #2
0
        public void TestAddList()
        {
            var excelReport = new ExcelReport("TestAddList", "Unknown", "sheet 1");

            excelReport.AddEmptyRows(5);


            var pesonList = new List <TestPerson>();

            for (int rowIndex = 1; rowIndex < 30000; rowIndex++)
            {
                var person = new TestPerson
                {
                    Age       = rowIndex,
                    FirstName = "Ivan",
                    LastName  = "Ivanov"
                };

                pesonList.Add(person);
            }

            excelReport.AddList(pesonList);

            excelReport.AddLogo(0, 0);

            excelReport.SaveToExcelFile(@"c:\\PesonList.xls");
        }
Пример #3
0
        public ActionResult CreateExcel(DevOpsReportParams @params)
        {
            try
            {
                var config = GetConfig();

                var report = new DevOpsReport(config, GetCustomFieldsFile());

                report.ExecMainReport(@params);

                var excel = new ExcelReport();

                var criteria = new Dictionary <string, string>
                {
                    { "Период", $"{@params.Start:dd.MM.yyyy} - {(@params.End ?? DateTime.Now.Date):dd.MM.yyyy}" },
                    { "Сотрудники", string.Join(", ", config.Employees.Where(x => @params.Employees.Contains(x.Name)).Select(x => x.NameShort).OrderBy(x => x)) },
                };

                excel.AddList(report.ActivityReport, criteria);
                excel.AddList(report.TaskReport, criteria);
                excel.AddList(report.WorkingTimeReport, criteria);
                excel.AddList(report.WorkingTimeDiffReport, criteria);

                var bytes = excel.GetXlsFile();

                var key = $"Execl{Guid.NewGuid().ToString()}";

                TempData[key] = new TmpFile
                {
                    Content  = bytes,
                    FileName = "Аналитический отчет.xlsx"
                };

                return(new JsonNetResult
                {
                    Data = new
                    {
                        key = key
                    }
                });
            }
            catch (Exception e)
            {
                return(new ExceptionResult(e));
            }
        }
Пример #4
0
        public void TestAddListWitCustomColums()
        {
            var excelReport = new ExcelReport("TestAddListWitCustomColums", "Unknown", "sheet 1");

            excelReport.AddEmptyRows(5);

            var pesonList = new List <TestPerson>();

            for (int rowIndex = 1; rowIndex < 30000; rowIndex++)
            {
                var person = new TestPerson
                {
                    Age       = rowIndex % 100,
                    FirstName = "Ivan",
                    LastName  = "Ivanov"
                };

                pesonList.Add(person);
            }

            var columns = new List <DataColumn> {
                DataColumn.GetRowNumberColumn("№"),
                new DataColumn {
                    FieldAlias = "Фамилия", FieldName = "LastName", ExcelColumWidth = 20
                },
                new DataColumn {
                    FieldAlias = "Имя", FieldName = "FirstName", ExcelColumWidth = 20
                },
                new DataColumn {
                    FieldAlias = "Возраст", FieldName = "Age", ExcelColumWidth = 20
                }
            };

            excelReport.AddList(pesonList, columns);

            excelReport.AddLogo(0, 0);

            excelReport.SaveToExcelFile(@"c:\\PesonListWitCustomColums.xls");
        }