OfficeIMO

API Reference

Class

SheetComposer

Namespace OfficeIMO.Excel.Fluent
Assembly OfficeIMO.Excel
Modifiers sealed

Simple multi-column layout for placing lightweight blocks side by side.

Inheritance

  • Object
  • SheetComposer

Constructors

public SheetComposer(ExcelDocument workbook, String sheetName, SheetTheme theme = null) #

Creates a new sheet and prepares a composer for adding content top-to-bottom. Also creates a hidden named range at the sheet top ("top_{sheet}") for navigation.

Parameters

workbook OfficeIMO.Excel.ExcelDocument requiredposition: 0
Target workbook.
sheetName System.String requiredposition: 1
Name of the sheet to create.
theme OfficeIMO.Excel.Fluent.SheetTheme = null optionalposition: 2
Optional theme controlling colors and spacing.

Methods

public SheetComposer AdvanceRows(Int32 rows) #
Returns: SheetComposer

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 System.Int32 requiredposition: 0
public SheetComposer ApplyColumnSizing(String a1Range, Action<ColumnSizingOptions> configure) #
Returns: SheetComposer

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 System.String requiredposition: 0
A1 range returned from TableFrom (e.g., "A10:F42").
configure System.Action{OfficeIMO.Excel.Fluent.ColumnSizingOptions} requiredposition: 1
Configure sizing options and header categories.
public SheetComposer BulletedList(IEnumerable<String> items) #
Returns: SheetComposer

Writes a simple bulleted list, one item per row.

Parameters

items System.Collections.Generic.IEnumerable{System.String} requiredposition: 0
public SheetComposer BulletedListWithFill(IEnumerable<String> items, String fillHex) #
Returns: SheetComposer

Bulleted list with background fill per item row.

Parameters

items System.Collections.Generic.IEnumerable{System.String} requiredposition: 0
fillHex System.String requiredposition: 1
public SheetComposer Callout(String kind, String title, String body, Int32 widthColumns = 8) #
Returns: SheetComposer

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

Parameters

kind System.String requiredposition: 0
title System.String requiredposition: 1
body System.String requiredposition: 2
widthColumns System.Int32 = 8 optionalposition: 3
public SheetComposer Columns(Int32 count, Action<ColumnComposer[]> configure, Int32 columnWidth = 3, Int32 gutter = 1, OverflowMode overflow = Throw) #
Returns: SheetComposer

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 System.Int32 requiredposition: 0
Number of columns (2–4 recommended).
configure System.Action{OfficeIMO.Excel.Fluent.SheetComposer.ColumnComposer[]} requiredposition: 1
Callback that receives an array of ColumnComposer objects.
columnWidth System.Int32 = 3 optionalposition: 2
Width per column in grid columns (for relative positioning only).
gutter System.Int32 = 1 optionalposition: 3
Spacing between columns in grid columns.
overflow OfficeIMO.Excel.Fluent.OverflowMode = Throw optionalposition: 4
Specifies how to handle content that exceeds the allocated width of a column.
public SheetComposer ColumnsAdaptive(IReadOnlyList<Action<ColumnComposer>> builders, Int32 gutter = 1) #
Returns: SheetComposer

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.Fluent.SheetComposer.ColumnComposer}} requiredposition: 0
gutter System.Int32 = 1 optionalposition: 1
public SheetComposer ColumnsAdaptiveRows(IReadOnlyList<IReadOnlyList<Action<ColumnComposer>>> rows, Int32 gutter = 1) #
Returns: SheetComposer

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.Fluent.SheetComposer.ColumnComposer}}} requiredposition: 0
gutter System.Int32 = 1 optionalposition: 1
public SheetComposer ConditionalColorScale(String rangeA1, String startHex, String endHex) #
Returns: SheetComposer

Adds a conditional color scale to the given range.

Parameters

rangeA1 System.String requiredposition: 0
startHex System.String requiredposition: 1
endHex System.String requiredposition: 2
public SheetComposer ConditionalDataBar(String rangeA1, String colorHex) #
Returns: SheetComposer

Adds a conditional data bar to the given range.

Parameters

rangeA1 System.String requiredposition: 0
colorHex System.String requiredposition: 1
public SheetComposer ConditionalIconSet(String rangeA1, IconSetValues set, Boolean showValue = true, Boolean reverse = false, Double[] percentThresholds = null, Double[] numberThresholds = null) #
Returns: SheetComposer

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

Parameters

rangeA1 System.String requiredposition: 0
set DocumentFormat.OpenXml.Spreadsheet.IconSetValues requiredposition: 1
showValue System.Boolean = true optionalposition: 2
reverse System.Boolean = false optionalposition: 3
percentThresholds System.Double[] = null optionalposition: 4
numberThresholds System.Double[] = null optionalposition: 5
public SheetComposer DefinitionList(IEnumerable<ValueTuple<String, Object>> items, Int32 columns = 2) #
Returns: SheetComposer

Alias for Int32).

Parameters

items System.Collections.Generic.IEnumerable{System.ValueTuple{System.String,System.Object}} requiredposition: 0
columns System.Int32 = 2 optionalposition: 1
public SheetComposer Finish(Boolean autoFitColumns = true, Boolean autoFitRows = false) #
Returns: SheetComposer

Applies optional autofit operations and returns the composer.

Parameters

autoFitColumns System.Boolean = true optionalposition: 0
autoFitRows System.Boolean = false optionalposition: 1
public SheetComposer FlowColumns(IReadOnlyList<IReadOnlyList<Action<ColumnComposer>>> columnGroups, Int32 columnWidth = 12, Int32 gutter = 2) #
Returns: SheetComposer

Renders a sequence of column blocks left-to-right using a fixed number of columns per band. Each band uses [[cref:OfficeIMO.Excel.Fluent.SheetComposer.Columns(System.Int32,System.Action{OfficeIMO.Excel.Fluent.SheetComposer.ColumnComposer[]},System.Int32,System.Int32,OfficeIMO.Excel.Fluent.OverflowMode)]] 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.Fluent.SheetComposer.ColumnComposer}}} requiredposition: 0
columnWidth System.Int32 = 12 optionalposition: 1
gutter System.Int32 = 2 optionalposition: 2
public SheetComposer FooterLogoUrl(String url, HeaderFooterPosition position = Right, Nullable<Double> widthPoints = null, Nullable<Double> heightPoints = null, String leftText = null, String centerText = null, String rightText = null) #
Returns: SheetComposer

Convenience: sets a footer logo from URL and optional footer text using the fluent builder.

Parameters

url System.String requiredposition: 0
position OfficeIMO.Excel.HeaderFooterPosition = Right optionalposition: 1
widthPoints System.Nullable{System.Double} = null optionalposition: 2
heightPoints System.Nullable{System.Double} = null optionalposition: 3
leftText System.String = null optionalposition: 4
centerText System.String = null optionalposition: 5
rightText System.String = null optionalposition: 6
public SheetComposer HeaderFooter(Action<HeaderFooterBuilder> configure) #
Returns: SheetComposer

Configures header/footer content and images via a builder.

Parameters

configure System.Action{OfficeIMO.Excel.Fluent.HeaderFooterBuilder} requiredposition: 0
public SheetComposer HeaderLogoUrl(String url, HeaderFooterPosition position = Right, Nullable<Double> widthPoints = null, Nullable<Double> heightPoints = null, String leftText = null, String centerText = null, String rightText = null) #
Returns: SheetComposer

Convenience: sets a header logo from URL and optional header text using the fluent builder.

Parameters

url System.String requiredposition: 0
position OfficeIMO.Excel.HeaderFooterPosition = Right optionalposition: 1
widthPoints System.Nullable{System.Double} = null optionalposition: 2
heightPoints System.Nullable{System.Double} = null optionalposition: 3
leftText System.String = null optionalposition: 4
centerText System.String = null optionalposition: 5
rightText System.String = null optionalposition: 6
public SheetComposer ImageAt(Int32 row, Int32 column, Byte[] bytes, String contentType = "image/png", Int32 widthPixels = 96, Int32 heightPixels = 32, Int32 offsetXPixels = 0, Int32 offsetYPixels = 0) #
Returns: SheetComposer

Inserts an image anchored to a specific cell.

Parameters

row System.Int32 requiredposition: 0
1-based row index.
column System.Int32 requiredposition: 1
1-based column index.
bytes System.Byte[] requiredposition: 2
Image bytes.
contentType System.String = "image/png" optionalposition: 3
Image content type (e.g., image/png).
widthPixels System.Int32 = 96 optionalposition: 4
Width in pixels.
heightPixels System.Int32 = 32 optionalposition: 5
Height in pixels.
offsetXPixels System.Int32 = 0 optionalposition: 6
Optional X offset in pixels.
offsetYPixels System.Int32 = 0 optionalposition: 7
Optional Y offset in pixels.
public SheetComposer ImageFromUrlAt(Int32 row, Int32 column, String url, Int32 widthPixels = 96, Int32 heightPixels = 32, Int32 offsetXPixels = 0, Int32 offsetYPixels = 0) #
Returns: SheetComposer

Downloads an image from URL and inserts it anchored at a specific cell.

Parameters

row System.Int32 requiredposition: 0
1-based row index.
column System.Int32 requiredposition: 1
1-based column index.
url System.String requiredposition: 2
Direct URL to an image.
widthPixels System.Int32 = 96 optionalposition: 3
Width in pixels.
heightPixels System.Int32 = 32 optionalposition: 4
Height in pixels.
offsetXPixels System.Int32 = 0 optionalposition: 5
Optional X offset in pixels.
offsetYPixels System.Int32 = 0 optionalposition: 6
Optional Y offset in pixels.
public SheetComposer KpiRow(IEnumerable<ValueTuple<String, Object>> kpis, Int32 perRow = 3, String labelFillHex = null) #
Returns: SheetComposer

Renders a compact KPI row of label/value pairs.

Parameters

kpis System.Collections.Generic.IEnumerable{System.ValueTuple{System.String,System.Object}} requiredposition: 0
perRow System.Int32 = 3 optionalposition: 1
labelFillHex System.String = null optionalposition: 2
Margins 2 overloads
public SheetComposer Margins(ExcelMarginPreset preset) #
Returns: SheetComposer

Applies a margin preset.

Parameters

preset OfficeIMO.Excel.ExcelMarginPreset requiredposition: 0
public SheetComposer Margins(Double left, Double right, Double top, Double bottom, Double header = 0.3, Double footer = 0.3) #
Returns: SheetComposer

Sets explicit margins in inches.

Parameters

left System.Double requiredposition: 0
right System.Double requiredposition: 1
top System.Double requiredposition: 2
bottom System.Double requiredposition: 3
header System.Double = 0.3 optionalposition: 4
footer System.Double = 0.3 optionalposition: 5
public SheetComposer Orientation(ExcelPageOrientation orientation) #
Returns: SheetComposer

Sets page orientation (Portrait/Landscape).

Parameters

orientation OfficeIMO.Excel.ExcelPageOrientation requiredposition: 0
public SheetComposer Paragraph(String text, Int32 widthColumns = 6) #
Returns: SheetComposer

Writes a paragraph-like line of text.

Parameters

text System.String requiredposition: 0
widthColumns System.Int32 = 6 optionalposition: 1
public SheetComposer PrintDefaults(Boolean showGridlines = false, UInt32 fitToWidth = 1, UInt32 fitToHeight = 0, String printAreaA1 = null) #
Returns: SheetComposer

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

Parameters

showGridlines System.Boolean = false optionalposition: 0
fitToWidth System.UInt32 = 1 optionalposition: 1
fitToHeight System.UInt32 = 0 optionalposition: 2
printAreaA1 System.String = null optionalposition: 3
public SheetComposer PropertiesGrid(IEnumerable<ValueTuple<String, Object>> properties, Int32 columns = 2) #
Returns: SheetComposer

Renders a compact grid of key/value pairs.

Parameters

properties System.Collections.Generic.IEnumerable{System.ValueTuple{System.String,System.Object}} requiredposition: 0
columns System.Int32 = 2 optionalposition: 1
public SheetComposer References(IEnumerable<String> urls) #
Returns: SheetComposer

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

Parameters

urls System.Collections.Generic.IEnumerable{System.String} requiredposition: 0
public SheetComposer RepeatHeaderColumns(Int32 firstCol, Int32 lastCol) #
Returns: SheetComposer

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

Parameters

firstCol System.Int32 requiredposition: 0
lastCol System.Int32 requiredposition: 1
public SheetComposer RepeatHeaderRows(Int32 firstRow, Int32 lastRow) #
Returns: SheetComposer

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

Parameters

firstRow System.Int32 requiredposition: 0
lastRow System.Int32 requiredposition: 1
public SheetComposer Score(String label, Double value, Double min = 0, Double max = 10) #
Returns: SheetComposer

Writes a labeled numeric score with a data bar visualization.

Parameters

label System.String requiredposition: 0
value System.Double requiredposition: 1
min System.Double = 0 optionalposition: 2
max System.Double = 10 optionalposition: 3
public SheetComposer Section(String text) #
Returns: SheetComposer

Writes a section header (bold with themed background).

Parameters

text System.String requiredposition: 0
public SheetComposer SectionLegend(String title, IReadOnlyList<String> headers, IEnumerable<IReadOnlyList<String>> rows, IDictionary<String, String> firstColumnFillByValue = null, String headerFillHex = null) #
Returns: SheetComposer

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 System.String requiredposition: 0
headers System.Collections.Generic.IReadOnlyList{System.String} requiredposition: 1
rows System.Collections.Generic.IEnumerable{System.Collections.Generic.IReadOnlyList{System.String}} requiredposition: 2
firstColumnFillByValue System.Collections.Generic.IDictionary{System.String,System.String} = null optionalposition: 3
headerFillHex System.String = null optionalposition: 4
public SheetComposer SectionWithAnchor(String text, String anchorName = null, Boolean backToTopLink = true, String backToTopText = "↑ Top") #
Returns: SheetComposer

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

Parameters

text System.String requiredposition: 0
anchorName System.String = null optionalposition: 1
backToTopLink System.Boolean = true optionalposition: 2
backToTopText System.String = "↑ Top" optionalposition: 3
public SheetComposer Spacer(Int32 rows = -1) #
Returns: SheetComposer

Adds vertical spacing by advancing the current row.

Parameters

rows System.Int32 = -1 optionalposition: 0
Number of rows to skip; when negative uses the theme default.
public String TableFrom<T>(IEnumerable<T> items, String title = null, Action<ObjectFlattenerOptions> configure = null, TableStyle style = TableStyleMedium9, Boolean autoFilter = true, Boolean freezeHeaderRow = true, Action<TableVisualOptions> visuals = null) #
Returns: String

Type Parameters

T

Parameters

items IEnumerable<T> requiredposition: 0
title String = null optionalposition: 1
configure Action<ObjectFlattenerOptions> = null optionalposition: 2
style TableStyle = TableStyleMedium9 optionalposition: 3
autoFilter Boolean = true optionalposition: 4
freezeHeaderRow Boolean = true optionalposition: 5
visuals Action<TableVisualOptions> = null optionalposition: 6
TableFrom``1(System.Collections.Generic.IEnumerable{``0} items, System.String title, System.Action{OfficeIMO.Excel.ObjectFlattenerOptions} configure, OfficeIMO.Excel.TableStyle style, System.Boolean autoFilter, System.Boolean freezeHeaderRow, System.Action{OfficeIMO.Excel.Fluent.TableVisualOptions} visuals) #

Flattens a sequence of objects into a table and renders it with a header row. Returns the A1 range used for the table.

Parameters

items System.Collections.Generic.IEnumerable{``0} required
title System.String required
configure System.Action{OfficeIMO.Excel.ObjectFlattenerOptions} required
style OfficeIMO.Excel.TableStyle required
autoFilter System.Boolean required
freezeHeaderRow System.Boolean required
visuals System.Action{OfficeIMO.Excel.Fluent.TableVisualOptions} required
public SheetComposer Title(String text, String subtitle = null) #
Returns: SheetComposer

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

Parameters

text System.String requiredposition: 0
subtitle System.String = null optionalposition: 1

Properties

public ExcelSheet Sheet { get; } #

The underlying sheet created by this composer.

public Int32 CurrentRow { get; } #

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