/// <summary>
        /// Adds new excel sheet.
        /// </summary>
        /// <param name="reportProvider">Report provider.</param>
        /// <param name="reportRows">Report rows.</param>
        /// <returns>Builder instance.</returns>
        public ExcelReportBuilder AddReportSheet(IReportProvider reportProvider, IEnumerable <IPropertyContainer> reportRows)
        {
            reportProvider.AssertArgumentNotNull(nameof(reportProvider));
            reportRows.AssertArgumentNotNull(nameof(reportRows));

            var sheetMetadata = reportProvider.GetMetadata <ExcelSheetMetadata>() ?? _defaultSheetMetadata;

            // Add a WorksheetPart to the WorkbookPart.
            WorkbookPart  workbookPart  = _documentContext.Document.WorkbookPart;
            uint          sheetCount    = workbookPart.GetSheetCount();
            WorksheetPart worksheetPart = workbookPart.AddNewPart <WorksheetPart>($"sheet{sheetCount+1}");

            var sheetContext = new SheetContext(_documentContext, worksheetPart, sheetMetadata, reportProvider);

            AddSheet(sheetContext);

            AddSheetData(sheetContext, reportRows);

            // External customization
            var customizeFunc = sheetContext.SheetMetadata?.GetValue(ExcelSheetMetadata.ConfigureSheet);

            customizeFunc?.Invoke(sheetContext);

            return(this);
        }
        /// <summary>
        /// Adds new excel sheet.
        /// </summary>
        /// <param name="reportProvider">Report provider.</param>
        /// <returns>Builder instance.</returns>
        public ExcelReportBuilder AddReportSheet(IReportProvider reportProvider)
        {
            reportProvider.AssertArgumentNotNull(nameof(reportProvider));

            var reportRows = reportProvider.GetReportRows();

            return(AddReportSheet(reportProvider, reportRows));
        }
 public SheetContext(
     DocumentContext documentContext,
     WorksheetPart worksheetPart,
     IExcelMetadata sheetMetadata,
     IReportProvider reportProvider)
 {
     DocumentContext = documentContext.AssertArgumentNotNull(nameof(documentContext));
     SheetMetadata   = sheetMetadata.AssertArgumentNotNull(nameof(sheetMetadata));
     ReportProvider  = reportProvider.AssertArgumentNotNull(nameof(reportProvider));
     WorksheetPart   = worksheetPart.AssertArgumentNotNull(nameof(worksheetPart));
 }