public NpoiExcelWorkbook(FileInfo pathToWorkbook, ReportOptions excelOptions) { pathToWorkbook.ThrowIfNull(nameof(pathToWorkbook)); _excelOptions = excelOptions.ThrowIfNull(nameof(excelOptions)); using (var file = new FileStream(pathToWorkbook.FullName, FileMode.Open, FileAccess.Read)) { _workbook = new XSSFWorkbook(file); } _formulaProvider = ExcelWrapperFactory.CreateFormulaProvider(excelOptions); }
public EpplusExcelWorkbook(ReportOptions excelOptions) { InitPackageLicence(); _excelOptions = excelOptions.ThrowIfNull(nameof(excelOptions)); _package = new ExcelPackage(); _formulaProvider = ExcelWrapperFactory.CreateFormulaProvider(excelOptions); _epplusLogger = new EpplusLogger(_package, ConfigOptions.Logger); _epplusLogger.AttachLogger(); RegisterFunctionModules(); }
public static IExcelWorkbook CreateWorkbook(FileInfo outputReportFile, ReportOptions reportOptions) { reportOptions.ThrowIfNull(nameof(reportOptions)); return(reportOptions.LibraryProvider switch { ExcelLibraryProvider.NPOI => new NpoiExcelWorkbook(outputReportFile, reportOptions), ExcelLibraryProvider.EPPlus => new EpplusExcelWorkbook(outputReportFile, reportOptions), _ => throw new ArgumentOutOfRangeException( nameof(reportOptions), reportOptions.LibraryProvider, $"Unknown Excel library provider: '{reportOptions.LibraryProvider.ToString()}'." ) });
public static IExcelCellHolder GetCellHolder(IExcelSheet sheet, ExcelColumnIndex columnIndex, int rowIndex, ReportOptions excelOptions) { sheet.ThrowIfNull(nameof(sheet)); excelOptions.ThrowIfNull(nameof(excelOptions)); return(excelOptions.CellCreationMode switch { ExcelCellCreationMode.Default => sheet.GetOrCreateCell(columnIndex, rowIndex), ExcelCellCreationMode.Centerized => sheet.GetOrCreateCenterizedCell(columnIndex, rowIndex), _ => throw new ArgumentOutOfRangeException( nameof(excelOptions), excelOptions.CellCreationMode, $"Unknown cell creation mode: '{excelOptions.CellCreationMode.ToString()}'." ) });
public NpoiExcelWorkbook(ReportOptions excelOptions) { _excelOptions = excelOptions.ThrowIfNull(nameof(excelOptions)); _workbook = new XSSFWorkbook(); _formulaProvider = ExcelWrapperFactory.CreateFormulaProvider(excelOptions); }
protected BaseExcelSheet(ReportOptions excelOptions, IExcelFormulaProvider provider) { _excelOptions = excelOptions.ThrowIfNull(nameof(excelOptions)); FormulaProvider = provider.ThrowIfNull(nameof(provider)); }