Esempio n. 1
0
 /// <summary>
 /// Adds report sheet if has any rows.
 /// </summary>
 /// <param name="reportBuilder">Source report builder.</param>
 /// <param name="reportProvider">Report provider for sheet.</param>
 /// <param name="rows">Rows for sheet.</param>
 /// <returns>The same report builder.</returns>
 public static ExcelReportBuilder AddReportSheetIfHasRows(
     this ExcelReportBuilder reportBuilder,
     IReportProvider reportProvider,
     IReadOnlyCollection <IPropertyContainer>?rows = null)
 {
     rows ??= reportProvider.GetReportRows().ToArray();
     return(rows?.Count > 0 ? reportBuilder.AddReportSheet(reportProvider, rows) : reportBuilder);
 }
        /// <summary>
        /// Creates new empty excel document and builder.
        /// </summary>
        /// <param name="targetStream">Output stream.</param>
        /// <param name="documentMetadata">Default excel document metadata.</param>
        /// <param name="settings">Optional report builder settings.</param>
        /// <returns>Builder instance.</returns>
        public static ExcelReportBuilder Create(
            Stream targetStream,
            ExcelDocumentMetadata?documentMetadata = null,
            IReportBuilderSettings?settings        = null)
        {
            targetStream.AssertArgumentNotNull(nameof(targetStream));

            SpreadsheetDocument document = SpreadsheetDocument.Create(targetStream, SpreadsheetDocumentType.Workbook);
            var builder = new ExcelReportBuilder(document, documentMetadata, settings);

            return(builder);
        }
        /// <summary>
        /// Creates new empty excel document and builder.
        /// </summary>
        /// <param name="outFilePath">Output file name.</param>
        /// <param name="documentMetadata">Default excel document metadata.</param>
        /// <param name="settings">Optional report builder settings.</param>
        /// <returns>Builder instance.</returns>
        public static ExcelReportBuilder Create(
            string outFilePath,
            ExcelDocumentMetadata?documentMetadata = null,
            IReportBuilderSettings?settings        = null)
        {
            outFilePath.AssertArgumentNotNull(nameof(outFilePath));

            SpreadsheetDocument document = SpreadsheetDocument.Create(outFilePath, SpreadsheetDocumentType.Workbook);
            var builder = new ExcelReportBuilder(document, documentMetadata, settings);

            return(builder);
        }