示例#1
0
        public void Save(ExcelPackage excelPackage, ExcelPackageModel excelPackageModel)
        {
            _log.Debug(string.Format("Saving ExcelPackage to {0}", excelPackageModel.SaveFilePath));

            var fileInfo = File.Create(excelPackageModel.SaveFilePath);

            excelPackage.SaveAs(fileInfo);
        }
示例#2
0
        public void Save(ExcelPackage excelPackage, ExcelPackageModel excelPackageModel)
        {
            _log.Debug(string.Format("Saving ExcelPackage to {0}", excelPackageModel.SaveFilePath));

            var fileInfo = File.Create(excelPackageModel.SaveFilePath);

            excelPackage.SaveAs(fileInfo);
        }
示例#3
0
        public ExcelPackage Create(ExcelPackageModel excelPackageModel)
        {
            ExcelPackage excelPackage;

            if (string.IsNullOrEmpty(excelPackageModel.TemplatePath))
            {
                _log.Debug(string.Format("Creating ExcelPackage"));
                excelPackage = new ExcelPackage();
            }
            else
            {
                _log.Debug(string.Format("Creating ExcelPackage using template {0}", excelPackageModel.TemplatePath));
                var fileInfo = new FileInfo(excelPackageModel.TemplatePath);
                excelPackage = new ExcelPackage(fileInfo);
            }

            return(excelPackage);
        }
示例#4
0
        public ExcelPackage Create(ExcelPackageModel excelPackageModel)
        {
            ExcelPackage excelPackage;

            if (string.IsNullOrEmpty(excelPackageModel.TemplatePath))
            {
                _log.Debug(string.Format("Creating ExcelPackage"));
                excelPackage = new ExcelPackage();
            }
            else
            {
                _log.Debug(string.Format("Creating ExcelPackage using template {0}", excelPackageModel.TemplatePath));
                var fileInfo = new FileInfo(excelPackageModel.TemplatePath);
                excelPackage = new ExcelPackage(fileInfo);
            }

            return excelPackage;
        }
示例#5
0
        public void ExportToExcel(IEnumerable<IEnumerable<object>> reports)
        {
            var packageModel = new ExcelPackageModel { SaveFilePath = string.Format("{0}.xlsx", Guid.NewGuid()) };

            var excelPackage = _excelPackageWriter.Create(packageModel);

            var sheetId = 0;
            foreach (var records in reports)
            {
                var excelWorksheet = _excelWorkSheetWriter.Create(excelPackage, new ExcelWorkSheetModel {Title = string.Format("Report{0}", sheetId)});

                _reflectionDataWriter.Write(excelWorksheet, DataWriterModel.Default, records);

                sheetId++;
            }

            _excelPackageWriter.Save(excelPackage, packageModel);
        }