示例#1
0
        public void ExportWithAttributesAndSomeSheetsNames()
        {
            IList <DummyPersonWithAttributes> dummyPeopleSheet1 = new List <DummyPersonWithAttributes>();
            IList <DummyPersonWithAttributes> dummyPeopleSheet2 = new List <DummyPersonWithAttributes>();
            IList <DummyPersonWithAttributes> dummyPeopleSheet3 = new List <DummyPersonWithAttributes>();

            for (int index = 0; index < 30; index++)
            {
                dummyPeopleSheet1.Add(DummyFactory.CreateDummyPersonWithAttributes());
            }

            for (int index = 0; index < 50; index++)
            {
                dummyPeopleSheet2.Add(DummyFactory.CreateDummyPersonWithAttributes());
            }

            for (int index = 0; index < 25; index++)
            {
                dummyPeopleSheet3.Add(DummyFactory.CreateDummyPersonWithAttributes());
            }

            IExcelExportEngine engine = new ExcelExportEngine();

            engine.AsExcel().SetFormat(ExcelVersion.XLS);
            engine.AsExcel().AddData(dummyPeopleSheet1, "Sheet Number 1");
            engine.AsExcel().AddData(dummyPeopleSheet2, "Another Sheet");
            engine.AsExcel().AddData(dummyPeopleSheet3, "Custom Name");
            var fileName = Guid.NewGuid().ToString() + "-with-attributes-some-sheets.xls";
            var filePath = PathConfig.BASE_PATH + fileName;

            engine.Export(filePath);
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            ExcelExportEngine excelExportEngine = new ExcelExportEngine();

            excelExportEngine.CreateSheet();
            excelExportEngine.Close();
        }
示例#3
0
        static void Main(string[] args)
        {
            var totalRows = 10;

            if (args.Length > 0)
            {
                int.TryParse(args[0], out totalRows);
            }

            var list = new List <Sample>(totalRows);

            for (int i = 1; i <= totalRows; i++)
            {
                list.Add(new Sample
                {
                    Id   = i,
                    Name = $"Sample {i}",
                });
            }

            var engine = new ExcelExportEngine();

            engine.SetFormat(ExcelVersion.XLSX);
            engine.AddData(list);
            var extenssao = ExcelVersion.XLSX.ToString().ToLower();
            var path      = $"{AppDomain.CurrentDomain.SetupInformation.ApplicationBase}Teste_{totalRows}.{extenssao}";

            engine.Export(path);
        }
示例#4
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (!File.Exists(textBoxFilePath.Text))
            {
                MessageBox.Show("Файл с не найден.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBoxFilePath.Focus();
                return;
            }

            try
            {
                switch (comboBoxFileType.Text)
                {
                case "Путь до xml файла с информацией о дневных кодах КСГ":
                    _dbEngine.Logger.WriteLog("Импортируем дневные коды");
                    string dayServiceData = ExcelExportEngine.GetServiceDataFromFile(textBoxFilePath.Text);

                    _dbEngine.Logger.WriteLog("Создаём объект DayServiceEngine");
                    _dbEngine.DayServiceEngine = new ServiceEngine(dayServiceData);

                    _dbEngine.Logger.WriteLog("Сохраняем новые услуги");
                    _dbEngine.SaveServices();
                    break;

                case "Путь до xml файла с информацией о ночных кодах КСГ":
                    _dbEngine.Logger.WriteLog("Импортируем ночные коды");
                    string nightServiceData = ExcelExportEngine.GetServiceDataFromFile(textBoxFilePath.Text);

                    _dbEngine.Logger.WriteLog("Создаём объект NightServiceEngine");
                    _dbEngine.NightServiceEngine = new ServiceEngine(nightServiceData);

                    _dbEngine.Logger.WriteLog("Сохраняем новые услуги");
                    _dbEngine.SaveServices();
                    break;

                case "Путь до xml файла с информацией о МКБ":
                    _dbEngine.Logger.WriteLog("Импортируем коды МКБ");
                    string mkbData = ExcelExportEngine.GetMkbDataFromFile(textBoxFilePath.Text);

                    _dbEngine.LoadMkb(mkbData);

                    _dbEngine.Logger.WriteLog("Сохраняем новые коды МКБ");
                    _dbEngine.SaveMkbs();

                    break;

                default:
                    MessageBox.Show("Не поддерживаемый режим импорта. Сообщите разработчику.", "Внутренняя ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                MessageBox.Show("Испорт успешно завершён", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#5
0
        /// <summary>
        /// Экспортировать список пациентов в Excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonExportToExcel_Click(object sender, EventArgs e)
        {
            var exportedPatientList = new List <PatientClass>();

            for (int i = 0; i < PatientList.Rows.Count; i++)
            {
                exportedPatientList.Add(_dbEngine.GetPatientById(Convert.ToInt32(PatientList.Rows[i].Cells[0].Value.ToString())));
            }

            ExcelExportEngine.Export(exportedPatientList, _dbEngine);
        }
        public void ExportWithAttributes()
        {
            IList<DummyPersonWithAttributes> dummyPeople = new List<DummyPersonWithAttributes>();
            for (int index = 0; index < 30; index++)
            {
                dummyPeople.Add(DummyFactory.CreateDummyPersonWithAttributes());
            }

            IExportEngine engine = new ExcelExportEngine();
            engine.AddData(dummyPeople);
            var fileName = Guid.NewGuid().ToString() + "-with-attributes.xls";
            var filePath = BASE_PATH + fileName;
            engine.Export(filePath);
        }
        public void ExportWithPlainClassAndSheetName()
        {
            IList<DummyPerson> dummyPeople = new List<DummyPerson>();
            for (int index = 0; index < 30; index++)
            {
                dummyPeople.Add(DummyFactory.CreateDummyPerson());
            }

            IExcelExportEngine engine = new ExcelExportEngine();
            engine.AsExcel().AddData(dummyPeople, "Dummy People");
            var fileName = Guid.NewGuid().ToString() + "-plain-class-sheets-names.xls";
            var filePath = BASE_PATH + fileName;
            engine.Export(filePath);
        }
示例#8
0
        private static void CreateFile(IList <AddressInfo> addresses)
        {
            IExportEngine engine = new ExcelExportEngine();

            engine.AsExcel().AddData <AddressInfo>(addresses, "sheet1");
            var path       = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var folderPath = string.Format(@"{0}\output\", path);

            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }

            engine.Export(folderPath + Guid.NewGuid().ToString() + ".xlsx");
        }
示例#9
0
        public void ExportWithAttributes()
        {
            IList <DummyPersonWithAttributes> dummyPeople = new List <DummyPersonWithAttributes>();

            for (int index = 0; index < 30; index++)
            {
                dummyPeople.Add(DummyFactory.CreateDummyPersonWithAttributes());
            }

            IExportEngine engine = new ExcelExportEngine();

            engine.AddData(dummyPeople);
            var fileName = Guid.NewGuid().ToString() + "-with-attributes.xlsx";
            var filePath = PathConfig.BASE_PATH + fileName;

            engine.Export(filePath);
        }
示例#10
0
        public void ExportWithPlainClassAndSheetName()
        {
            IList <DummyPerson> dummyPeople = new List <DummyPerson>();

            for (int index = 0; index < 30; index++)
            {
                dummyPeople.Add(DummyFactory.CreateDummyPerson());
            }

            IExcelExportEngine engine = new ExcelExportEngine();

            engine.AsExcel().SetFormat(ExcelVersion.XLS);
            engine.AsExcel().AddData(dummyPeople, "Dummy People");
            var fileName = Guid.NewGuid().ToString() + "-plain-class-sheets-names.xls";
            var filePath = PathConfig.BASE_PATH + fileName;

            engine.Export(filePath);
        }
示例#11
0
        public void ExportWithAttributesAndRuntimeRename()
        {
            IList <DummyPersonWithAttributes> dummyPeople = new List <DummyPersonWithAttributes>();

            for (int index = 0; index < 30; index++)
            {
                dummyPeople.Add(DummyFactory.CreateDummyPersonWithAttributes());
            }

            IExportEngine engine = new ExcelExportEngine();
            var           key    = engine.AddData(dummyPeople);

            engine.AddColumnsNames <DummyPersonWithAttributes>(key, x => x.Name, "this is a new name LOL!");
            var fileName = Guid.NewGuid().ToString() + "-with-runtime-rename.xlsx";
            var filePath = PathConfig.BASE_PATH + fileName;

            engine.Export(filePath);
        }
示例#12
0
        public void ExportWithMixOrder()
        {
            IList <DummyPersonWithMixOrder> dummyPeople = new List <DummyPersonWithMixOrder>();

            for (int index = 0; index < 30; index++)
            {
                dummyPeople.Add(DummyFactory.CreateDummyPersonWithMixOrder());
            }

            IExportEngine engine = new ExcelExportEngine();

            engine.AsExcel().SetFormat(ExcelVersion.XLS);
            engine.AddData(dummyPeople);
            var fileName = Guid.NewGuid().ToString() + "-mix-order-class.xls";
            var filePath = PathConfig.BASE_PATH + fileName;

            engine.Export(filePath);
        }
示例#13
0
        public void ExportWithResourceHeaderAttributeWithOtherCulture()
        {
            IList <DummyPersonWithAttributesAndResource> dummyPeople = new List <DummyPersonWithAttributesAndResource>();

            for (int index = 0; index < 30; index++)
            {
                dummyPeople.Add(DummyFactory.CreateDummyPersonWithAttributesAndResource());
            }

            System.Threading.Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US");
            System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

            IExportEngine engine = new ExcelExportEngine();

            engine.AsExcel().SetFormat(ExcelVersion.XLS);
            engine.AddData(dummyPeople);
            var fileName = Guid.NewGuid().ToString() + "-some-header-class.xls";
            var filePath = PathConfig.BASE_PATH + fileName;

            engine.Export(filePath);
        }
示例#14
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (!File.Exists(textBoxDayKSGPath.Text))
            {
                MessageBox.Show("Файл с информацией о дневных кодах КСГ не найден.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBoxDayKSGPath.Focus();
                return;
            }

            if (!File.Exists(textBoxNightKSGPath.Text))
            {
                MessageBox.Show("Файл с информацией о ночных кодах КСГ не найден.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBoxNightKSGPath.Focus();
                return;
            }

            try
            {
                _dbEngine.Logger.WriteLog("Импортируем дневные коды");
                string dayKSGData = ExcelExportEngine.GetKSGDataFromFile(textBoxDayKSGPath.Text);
                _dbEngine.Logger.WriteLog("Импортируем ночные коды");
                string nightKSGData = ExcelExportEngine.GetKSGDataFromFile(textBoxNightKSGPath.Text);

                _dbEngine.Logger.WriteLog("Создаём объект DayMKBEngine");
                _dbEngine.DayMKBEngine = new MKBEngine(dayKSGData);
                _dbEngine.Logger.WriteLog("Создаём объект NightMKBEngine");
                _dbEngine.NightMKBEngine = new MKBEngine(nightKSGData);

                _dbEngine.Logger.WriteLog("Сохраняем новые объекты");
                _dbEngine.SaveKSG();

                _dbEngine.Logger.WriteLog("Закрываем окно");
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public void ExportWithAttributesAndSomeSheetsNames()
        {
            IList<DummyPersonWithAttributes> dummyPeopleSheet1 = new List<DummyPersonWithAttributes>();
            IList<DummyPersonWithAttributes> dummyPeopleSheet2 = new List<DummyPersonWithAttributes>();
            IList<DummyPersonWithAttributes> dummyPeopleSheet3 = new List<DummyPersonWithAttributes>();
            
            for (int index = 0; index < 30; index++)
            {
                dummyPeopleSheet1.Add(DummyFactory.CreateDummyPersonWithAttributes());
            }

            for (int index = 0; index < 50; index++)
            {
                dummyPeopleSheet2.Add(DummyFactory.CreateDummyPersonWithAttributes());
            }

            for (int index = 0; index < 25; index++)
            {
                dummyPeopleSheet3.Add(DummyFactory.CreateDummyPersonWithAttributes());
            }

            IExcelExportEngine engine = new ExcelExportEngine();
            engine.AsExcel().AddData(dummyPeopleSheet1, "Sheet Number 1");
            engine.AsExcel().AddData(dummyPeopleSheet2, "Another Sheet");
            engine.AsExcel().AddData(dummyPeopleSheet3, "Custom Name");
            var fileName = Guid.NewGuid().ToString() + "-with-attributes-some-sheets.xls";
            var filePath = BASE_PATH + fileName;
            engine.Export(filePath);
        }
        public void ExportIntensiveUsage()
        {
            IList<DummyPerson> dummyPeople = new List<DummyPerson>();
            for (int index = 0; index < 65000; index++)
            {
                dummyPeople.Add(DummyFactory.CreateDummyPerson());
            }

            IExportEngine engine = new ExcelExportEngine();
            engine.AddData(dummyPeople);
            var fileName = Guid.NewGuid().ToString() + "-intensive.xls";
            var filePath = BASE_PATH + fileName;
            engine.Export(filePath);
        }
        public void ExportWithResourceHeaderAttributeWithOtherCulture()
        {
            IList<DummyPersonWithAttributesAndResource> dummyPeople = new List<DummyPersonWithAttributesAndResource>();
            for (int index = 0; index < 30; index++)
            {
                dummyPeople.Add(DummyFactory.CreateDummyPersonWithAttributesAndResource());
            }

            System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

            IExportEngine engine = new ExcelExportEngine();
            engine.AddData(dummyPeople);
            var fileName = Guid.NewGuid().ToString() + "-some-header-class.xls";
            var filePath = BASE_PATH + fileName;
            engine.Export(filePath);
        }