コード例 #1
0
ファイル: ReportsLogic.cs プロジェクト: dgormash/StatToExcel
        public void Start(DateTime startDate, DateTime endDate)
        {
            var dbWorker          = new OracleWorker("192.168.192.1", "gaidev", "mainowner");
            var statementSelector = new SelectStatementChooser();

            //Прогоняем весь список отделов
            for (var i = 0; i <= _departmentList.Departments.Length - 1; i++)
            {
                //MainWindow.UpdateLabels(, _departmentList.Departments[i].Name);

                var parametrs = new Parametrs
                {
                    BeginDate    = startDate,
                    EndDate      = endDate,
                    DepartmentId = _departmentList.Departments[i].Id
                };

                var excelWorker = new ExcelWorker();
                //Прогоняем список процедур
                for (var j = 0; j <= _procedures.ProcedureName.Length - 1; j++)
                {
                    dbWorker.ExecuteProcedure(_procedures.ProcedureName[j], parametrs);
                    //var result = dbWorker.SelectData(_tables.TableNames[j]);
                    var result = dbWorker.SelectData(statementSelector.GetCommand(j));

                    var excelParameters = new ExcelParametrs
                    {
                        Data       = result,
                        Department = _departmentList.Departments[i].Name,
                        TableName  = _tables.TableNames[j]
                    };



                    excelWorker.MakeExcelReport(excelParameters);
                }
                excelWorker.SaveDocument(_departmentList.Departments[i].Name);
            }

            MessageBox.Show("Работа программы завершена", "Нате вам!!!");
        }
コード例 #2
0
        public void MakeExcelReport(ExcelParametrs parametrs)
        {
            var sheetName = string.Empty;

            switch (parametrs.TableName)
            {
            case "STAT_LISH_NS42":
                sheetName = "Отсутсвие мер (этап 42)";
                break;

            case "STAT_LISH_NS32":
                sheetName = "Нар. ср. напр. в суд (этап 32)";
                break;

            case "STAT_LISH_1207":
                sheetName = "Несост-ие по ст. 12.7 ч.2";
                break;

            case "STAT_LISH_264":
                sheetName = "Невозб-ие ст. 264 прим. 1";
                break;

            case "STAT_LISH_2025":
                sheetName = "Несост-ие по ст. 20.25";
                break;

            case "STAT_LISH_NOTPAY":
                sheetName = "Выдача ВУ без оплаты";
                break;

            case "STAT_LISH_FSSP":
                sheetName = "Ненапр-ие в ФССП";
                break;

            case "STAT_LISH_povt":
                sheetName = "Неприм-ие повторности";
                break;
            }

            var sheet = _book.CreateSheet(sheetName);
            var style = _book.CreateCellStyle();

            style.BorderLeft   = BorderStyle.Thin;
            style.BorderBottom = BorderStyle.Thin;
            style.BorderRight  = BorderStyle.Thin;
            style.BorderTop    = BorderStyle.Thin;

            style.Alignment         = HorizontalAlignment.Center;
            style.VerticalAlignment = VerticalAlignment.Center;

            var font = _book.CreateFont();

            font.Color = HSSFColor.COLOR_NORMAL;
            font.FontHeightInPoints = 10;
            font.FontName           = "Courier New";
            style.SetFont(font);

            if (parametrs.Data != null)
            {
                for (var i = 0; i <= parametrs.Data.Count - 1; i++)
                {
                    var row = sheet.CreateRow(i);

                    _arr = ((IEnumerable)parametrs.Data[i]).Cast <object>().Select(x => x.ToString()).ToArray();
                    for (var j = 0; j <= _arr.Length - 1; j++)
                    {
                        var cell = row.CreateCell(j);
                        cell.SetCellType(CellType.String);
                        cell.CellStyle = style;
                        cell.SetCellValue(_arr[j]);
                    }
                }

                for (var j = 0; j <= _arr.Length - 1; j++)
                {
                    sheet.AutoSizeColumn(j);
                }
            }
            else
            {
                var row  = sheet.CreateRow(0);
                var cell = row.CreateCell(0);
                cell.SetCellType(CellType.String);
                cell.SetCellValue("Нет данных для отображения");
                sheet.AutoSizeColumn(0);
            }
        }