public static Workbook ToExcelWorkbook( this Report report, ReportToWorkbookProjectionContext context = null) { if (report == null) { throw new ArgumentNullException(nameof(report)); } context = context ?? new ReportToWorkbookProjectionContext(); // Setup the workbook var result = General.CreateStandardWorkbook().RemoveDefaultWorksheet(); // Add document properties var documentProperties = context.BuildDocumentPropertiesDelegate == null ? new DocumentProperties() : context.BuildDocumentPropertiesDelegate(report.Title); // If report has a timestamp, should we set BuiltInDocumentPropertyKind.CreationDate and LastSaveTime to that timestamp? // Should those properties reflect when the workbook was created or when the report was created? result.SetDocumentProperties(documentProperties); // Add sections foreach (var section in report.Sections) { var worksheet = result.Worksheets.Add(section.Name); var cursors = new Cursors { ChromeCursor = new CellCursor(worksheet), }; // On first pass, add data. cursors.AddSection(section, context, PassKind.Data, report); // On second pass, apply formatting. cursors.AddSection(section, context, PassKind.Formatting, report); } return(result); }