Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

ExcelReportBuilder

OfficeIMO.Excel

Namespace
OfficeIMO.Excel
Assembly
OfficeIMO.Excel
Source revision
e163ccb36643 with working tree changes
Modifiers
sealed

Neutral, Excel-first wrapper for building stacked worksheet content.

Inheritance

  • object
  • ExcelReportBuilder

Usage

Explore 31 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Methods

AddImage 3 overloads
public ExcelImage AddImage(int row, int column, byte[] imageBytes, ExcelImageOptions? options = null) #

Adds an image through the worksheet and returns its attached image.

Parameters

row int required
column int required
imageBytes byte[] required
options OfficeIMO.Excel.ExcelImageOptions? = null optional

Returns

ExcelImage
public ExcelImage AddImage(int row, int column, string path, ExcelImageOptions? options = null) #

Adds an image through the worksheet and returns its attached image.

Parameters

row int required
column int required
path string required
options OfficeIMO.Excel.ExcelImageOptions? = null optional

Returns

ExcelImage
public ExcelImage AddImage(int row, int column, Stream stream, ExcelImageOptions? options = null) #

Adds an image through the worksheet and returns its attached image.

Parameters

row int required
column int required
stream System.IO.Stream required
options OfficeIMO.Excel.ExcelImageOptions? = null optional

Returns

ExcelImage
AddImageAsync 3 overloads
public Task<ExcelImage> AddImageAsync(int row, int column, string path, ExcelImageOptions? options = null, CancellationToken cancellationToken = default) #

Loads an image asynchronously through the worksheet and returns its attached image.

Parameters

row int required
column int required
path string required
options OfficeIMO.Excel.ExcelImageOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<ExcelImage>
public Task<ExcelImage> AddImageAsync(int row, int column, Stream stream, ExcelImageOptions? options = null, CancellationToken cancellationToken = default) #

Loads an image asynchronously through the worksheet and returns its attached image.

Parameters

row int required
column int required
stream System.IO.Stream required
options OfficeIMO.Excel.ExcelImageOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<ExcelImage>
public Task<ExcelImage> AddImageAsync(int row, int column, Uri uri, ExcelImageOptions? options = null, CancellationToken cancellationToken = default) #

Loads an image asynchronously through the worksheet and returns its attached image.

Parameters

row int required
column int required
uri System.Uri required
options OfficeIMO.Excel.ExcelImageOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<ExcelImage>
public ExcelTable AddTable(DataTable table, string? title = null, Action<ObjectFlattenerOptions>? configure = null, ExcelTableStyle style = TableStyleMedium9, bool autoFilter = true, bool freezeHeaderRow = true, Action<ExcelTableVisualOptions>? visuals = null) #

Renders a fixed-schema DataTable as an editable Excel table without generic object flattening. The DataTable schema order is preserved unless the projection configuration selects another order.

Parameters

table System.Data.DataTable required
Source table whose rows and schema are already materialized.
title string? = null optional
Optional section title and table name.
configure System.Action<OfficeIMO.Data.ObjectFlattenerOptions>? = null optional
Optional column selection, exclusion, ordering, header, and materialization-limit configuration. The fixed-schema overload defaults ObjectFlattenerOptions.MaxCells to ExcelReportBuilder.DefaultDataTableMaxCells instead of the lower generic object-flattening limit.
style OfficeIMO.Excel.ExcelTableStyle = TableStyleMedium9 optional
Built-in Excel table style.
autoFilter bool = true optional
Whether table filter buttons are included.
freezeHeaderRow bool = true optional
Whether rows through the table header are frozen.
visuals System.Action<OfficeIMO.Excel.ExcelTableVisualOptions>? = null optional
Optional table visual configuration.

Returns

ExcelTable The editable native table.
public ExcelTable AddTable<T>(IEnumerable<T?> items, string? title = null, Action<ObjectFlattenerOptions>? configure = null, ExcelTableStyle style = TableStyleMedium9, bool autoFilter = true, bool freezeHeaderRow = true, Action<ExcelTableVisualOptions>? visuals = null) #

Flattens a sequence of objects into a table and renders it with a header row. Returns the editable native table.

Type Parameters

T

Parameters

items System.Collections.Generic.IEnumerable<T?> required
title string? = null optional
configure System.Action<OfficeIMO.Data.ObjectFlattenerOptions>? = null optional
style OfficeIMO.Excel.ExcelTableStyle = TableStyleMedium9 optional
autoFilter bool = true optional
freezeHeaderRow bool = true optional
visuals System.Action<OfficeIMO.Excel.ExcelTableVisualOptions>? = null optional

Returns

ExcelTable
public ExcelReportBuilder AdvanceRows(int rows) #

Advances the composer by an exact number of rows without applying themed spacing semantics. Useful after manual cell writes where the composer did not track row changes.

Parameters

rows int required
public ExcelReportBuilder ApplyColumnSizing(string? a1Range, Action<ExcelColumnSizingOptions> configure) #

Applies clamped widths and optional wrap based on table headers for a given A1 range. The first row of the range is treated as the header row.

Parameters

a1Range string? required
A1 range returned from AddTable (e.g., "A10:F42").
configure System.Action<OfficeIMO.Excel.ExcelColumnSizingOptions> required
Configure sizing options and header categories.
public ExcelReportBuilder BulletedList(IEnumerable<string> items) #

Writes a simple bulleted list, one item per row.

Parameters

items System.Collections.Generic.IEnumerable<string> required
public ExcelReportBuilder BulletedListWithFill(IEnumerable<string> items, OfficeColor fill) #

Bulleted list with background fill per item row.

Parameters

items System.Collections.Generic.IEnumerable<string> required
Items to write, one per row.
fill OfficeIMO.OfficeColor required
Background color; native theme roles keep their theme slot.
public ExcelReportBuilder Callout(OfficeCalloutKind kind, string title, string body, int widthColumns = 8) #

Inserts a simple callout (admonition) band consisting of a bold title row and a body row.

Parameters

kind OfficeIMO.OfficeCalloutKind required
title string required
body string required
widthColumns int = 8 optional
public ExcelReportBuilder Columns(int count, Action<ColumnComposer[]> configure, int columnWidth = 3, int gutter = 1, ExcelReportOverflowMode overflow = Throw) #

Places N columns side-by-side starting at the current row. Each action receives a ColumnComposer scoped to its own column. The main composer advances to the maximum height used by the columns.

Parameters

count int required
Number of columns (2–4 recommended).
configure System.Action<OfficeIMO.Excel.ExcelReportBuilder.ColumnComposer[]> required
Callback that receives an array of ColumnComposer objects.
columnWidth int = 3 optional
Width per column in grid columns (for relative positioning only).
gutter int = 1 optional
Spacing between columns in grid columns.
overflow OfficeIMO.Excel.ExcelReportOverflowMode = Throw optional
Specifies how to handle content that exceeds the allocated width of a column.
public ExcelReportBuilder ColumnsAdaptive(IReadOnlyList<Action<ColumnComposer>> builders, int gutter = 1) #

Places columns left-to-right starting at the current row using adaptive widths derived from each column's content. Each column is rendered at the computed base column and the next column starts at (previous end + 1 + gutter).

Parameters

builders System.Collections.Generic.IReadOnlyList<System.Action<OfficeIMO.Excel.ExcelReportBuilder.ColumnComposer>> required
gutter int = 1 optional
public ExcelReportBuilder ColumnsAdaptiveRows(IReadOnlyList<IReadOnlyList<Action<ColumnComposer>>> rows, int gutter = 1) #

Renders multiple rows of adaptive columns. Each inner list is a left-to-right band; rows stack vertically.

Parameters

rows System.Collections.Generic.IReadOnlyList<System.Collections.Generic.IReadOnlyList<System.Action<OfficeIMO.Excel.ExcelReportBuilder.ColumnComposer>>> required
gutter int = 1 optional
public ExcelReportBuilder ConditionalColorScale(string rangeA1, OfficeColor startColor, OfficeColor endColor) #

Adds a conditional color scale to the given range.

Parameters

rangeA1 string required
A1-style range to format.
startColor OfficeIMO.OfficeColor required
Starting color; native theme roles keep their theme slot.
endColor OfficeIMO.OfficeColor required
Ending color; native theme roles keep their theme slot.
public ExcelReportBuilder ConditionalDataBar(string rangeA1, OfficeColor color) #

Adds a conditional data bar to the given range.

Parameters

rangeA1 string required
A1-style range to format.
color OfficeIMO.OfficeColor required
Bar color; native theme roles keep their theme slot.
public ExcelReportBuilder ConditionalIconSet(string rangeA1, ExcelIconSet set, bool showValue = true, bool reverse = false, double[]? percentThresholds = null, double[]? numberThresholds = null) #

Adds an icon set conditional formatting rule to the given range.

Parameters

rangeA1 string required
set OfficeIMO.Excel.ExcelIconSet required
showValue bool = true optional
reverse bool = false optional
percentThresholds double[]? = null optional
numberThresholds double[]? = null optional
public ExcelReportBuilder Finish(bool autoFitColumns = true, bool autoFitRows = false) #

Applies optional autofit operations and returns the composer.

Parameters

autoFitColumns bool = true optional
autoFitRows bool = false optional
public ExcelReportBuilder FlowColumns(IReadOnlyList<IReadOnlyList<Action<ColumnComposer>>> columnGroups, int columnWidth = 12, int gutter = 2) #

Renders a sequence of column blocks left-to-right using a fixed number of columns per band. Each band uses ExcelReportBuilder.Columns under the hood and advances the composer by the tallest block in that band.

Parameters

columnGroups System.Collections.Generic.IReadOnlyList<System.Collections.Generic.IReadOnlyList<System.Action<OfficeIMO.Excel.ExcelReportBuilder.ColumnComposer>>> required
columnWidth int = 12 optional
gutter int = 2 optional
FooterLogoFromUrlAsync 2 overloads
public async Task<ExcelReportBuilder> FooterLogoFromUrlAsync(string url, ExcelHeaderFooterPosition position = Right, OfficeLength? width = null, OfficeLength? height = null, string? leftText = null, string? centerText = null, string? rightText = null, CancellationToken cancellationToken = default) #

Asynchronously sets a footer logo from a URL and optional footer text.

Parameters

url string required
position OfficeIMO.Excel.ExcelHeaderFooterPosition = Right optional
width OfficeIMO.OfficeLength? = null optional
height OfficeIMO.OfficeLength? = null optional
leftText string? = null optional
centerText string? = null optional
rightText string? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<ExcelReportBuilder>
public async Task<ExcelReportBuilder> FooterLogoFromUrlAsync(string url, OfficeRemoteImageLoadOptions remoteImageOptions, ExcelHeaderFooterPosition position = Right, OfficeLength? width = null, OfficeLength? height = null, string? leftText = null, string? centerText = null, string? rightText = null, CancellationToken cancellationToken = default) #

Sets a footer logo using an explicit remote-network policy.

Parameters

url string required
remoteImageOptions OfficeIMO.Drawing.OfficeRemoteImageLoadOptions required
position OfficeIMO.Excel.ExcelHeaderFooterPosition = Right optional
width OfficeIMO.OfficeLength? = null optional
height OfficeIMO.OfficeLength? = null optional
leftText string? = null optional
centerText string? = null optional
rightText string? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<ExcelReportBuilder>
HeaderLogoFromUrlAsync 2 overloads
public async Task<ExcelReportBuilder> HeaderLogoFromUrlAsync(string url, ExcelHeaderFooterPosition position = Right, OfficeLength? width = null, OfficeLength? height = null, string? leftText = null, string? centerText = null, string? rightText = null, CancellationToken cancellationToken = default) #

Asynchronously sets a header logo from a URL and optional header text.

Parameters

url string required
position OfficeIMO.Excel.ExcelHeaderFooterPosition = Right optional
width OfficeIMO.OfficeLength? = null optional
height OfficeIMO.OfficeLength? = null optional
leftText string? = null optional
centerText string? = null optional
rightText string? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<ExcelReportBuilder>
public async Task<ExcelReportBuilder> HeaderLogoFromUrlAsync(string url, OfficeRemoteImageLoadOptions remoteImageOptions, ExcelHeaderFooterPosition position = Right, OfficeLength? width = null, OfficeLength? height = null, string? leftText = null, string? centerText = null, string? rightText = null, CancellationToken cancellationToken = default) #

Sets a header logo using an explicit remote-network policy.

Parameters

url string required
remoteImageOptions OfficeIMO.Drawing.OfficeRemoteImageLoadOptions required
position OfficeIMO.Excel.ExcelHeaderFooterPosition = Right optional
width OfficeIMO.OfficeLength? = null optional
height OfficeIMO.OfficeLength? = null optional
leftText string? = null optional
centerText string? = null optional
rightText string? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<ExcelReportBuilder>
public ExcelReportBuilder KpiRow(IEnumerable<ValueTuple<string, object?>> kpis, int perRow = 3, OfficeColor? labelFill = null) #

Renders a compact KPI row of label/value pairs.

Parameters

kpis System.Collections.Generic.IEnumerable<System.ValueTuple<string, object?>> required
Label/value pairs to render.
perRow int = 3 optional
Number of KPIs per row.
labelFill OfficeIMO.OfficeColor? = null optional
Optional label fill; null uses the report key fill.
Margins 2 overloads
public ExcelReportBuilder Margins(ExcelMarginPreset preset) #

Applies a margin preset.

Parameters

preset OfficeIMO.Excel.ExcelMarginPreset required
public ExcelReportBuilder Margins(OfficeLength left, OfficeLength right, OfficeLength top, OfficeLength bottom, OfficeLength? header = null, OfficeLength? footer = null) #

Sets physical margins; omitted header/footer margins are 0.3 inches.

Parameters

left OfficeIMO.OfficeLength required
right OfficeIMO.OfficeLength required
top OfficeIMO.OfficeLength required
bottom OfficeIMO.OfficeLength required
header OfficeIMO.OfficeLength? = null optional
footer OfficeIMO.OfficeLength? = null optional
public ExcelReportBuilder Orientation(OfficePageOrientation orientation) #

Sets page orientation (Portrait/Landscape).

Parameters

orientation OfficeIMO.OfficePageOrientation required
public ExcelReportBuilder Paragraph(string text, int widthColumns = 6) #

Writes a paragraph-like line of text.

Parameters

text string required
widthColumns int = 6 optional
public ExcelReportBuilder PrintDefaults(bool showGridlines = false, uint fitToWidth = 1, uint fitToHeight = 0, string? printAreaA1 = null) #

Applies sensible print defaults: gridlines off, fit to width, and optional print area.

Parameters

showGridlines bool = false optional
fitToWidth uint = 1 optional
fitToHeight uint = 0 optional
printAreaA1 string? = null optional
public ExcelReportBuilder PropertiesGrid(IEnumerable<ValueTuple<string, object?>> properties, int columns = 2) #

Renders a compact grid of key/value pairs.

Parameters

properties System.Collections.Generic.IEnumerable<System.ValueTuple<string, object?>> required
columns int = 2 optional
public ExcelReportBuilder References(IEnumerable<string> urls) #

Writes a simple References section with each URL as a hyperlink.

Parameters

urls System.Collections.Generic.IEnumerable<string> required
public ExcelReportBuilder RepeatHeaderColumns(int firstCol, int lastCol) #

Repeats header columns when printing (1-based inclusive).

Parameters

firstCol int required
lastCol int required
public ExcelReportBuilder RepeatHeaderRows(int firstRow, int lastRow) #

Repeats header rows when printing (1-based inclusive).

Parameters

firstRow int required
lastRow int required
public ExcelReportBuilder Score(string label, double value, double min = 0, double max = 10) #

Writes a labeled numeric score with a data bar visualization.

Parameters

label string required
value double required
min double = 0 optional
max double = 10 optional
public ExcelReportBuilder Section(string text) #

Writes a section header (bold with themed background).

Parameters

text string required
public ExcelReportBuilder SectionLegend(string? title, IReadOnlyList<string> headers, IEnumerable<IReadOnlyList<string>> rows, IDictionary<string, OfficeColor>? firstColumnFillByValue = null, OfficeColor? headerFill = null) #

Renders a compact legend block with an optional title, column headers, and rows. Optionally colors the first column using a value→color mapping.

Parameters

title string? required
Optional section title.
headers System.Collections.Generic.IReadOnlyList<string> required
Legend column headers.
rows System.Collections.Generic.IEnumerable<System.Collections.Generic.IReadOnlyList<string>> required
Legend row values.
firstColumnFillByValue System.Collections.Generic.IDictionary<string, OfficeIMO.OfficeColor>? = null optional
Optional first-column colors, using the dictionary's key comparer.
headerFill OfficeIMO.OfficeColor? = null optional
Optional header fill; null uses the report key fill.
public ExcelReportBuilder SectionWithAnchor(string text, string? anchorName = null, bool backToTopLink = true, string backToTopText = "↑ Top") #

Inserts a section header and a back-to-top link (explicit A1 link).

Parameters

text string required
anchorName string? = null optional
backToTopLink bool = true optional
backToTopText string = "↑ Top" optional
public ExcelReportBuilder Spacer(int rows = -1) #

Adds vertical spacing by advancing the current row.

Parameters

rows int = -1 optional
Number of rows to skip; when negative uses the theme default.
public ExcelReportBuilder Title(string text, string? subtitle = null) #

Writes a title (bold with themed background) and optional subtitle.

Parameters

text string required
subtitle string? = null optional

Properties

public ExcelSheet Sheet { get; } #

The worksheet receiving report content.

public int CurrentRow { get; } #

Current row where the next write occurs (1-based).

Fields

public const long DefaultDataTableMaxCells #

Default maximum number of cells written by the fixed-schema DataTable overload, including the header row.

Value: 5000000