HtmlForgeX

API Reference

Class

EmailTable

Namespace HtmlForgeX.Email
Assembly HtmlForgeX.Email
Base Element
Implements
ILayoutAware ISpaceable<EmailTable> IRoundable<EmailTable> IRoundable

Represents an email-compatible table component for displaying structured data.

Inheritance

Constructors

EmailTable 2 overloads
public EmailTable() #

Initializes a new instance of the EmailTable class.

public EmailTable(IEnumerable<Object> data) #

Initializes a new instance of the EmailTable class with data.

Parameters

data System.Collections.Generic.IEnumerable{System.Object} requiredposition: 0
The data collection to populate the table.

Methods

AddHeader 6 overloads
public EmailTable AddHeader(String text, Alignment align, Int32 colspan = 1) #
Returns: EmailTable

Adds a header to the table.

Parameters

text System.String requiredposition: 0
The header text.
align System.String = "left" requiredposition: 1
The text alignment.
colspan System.Int32 = 1 optionalposition: 2
The column span.

Returns

The EmailTable object, allowing for method chaining.

public EmailTable AddHeader(String text, String align, Int32 colspan, String width, String mobileText) #
Returns: EmailTable

Adds a header to the table with optional width and mobile text.

Parameters

text System.String requiredposition: 0
align System.String requiredposition: 1
colspan System.Int32 requiredposition: 2
width System.String requiredposition: 3
mobileText System.String requiredposition: 4
public EmailTable AddHeader(params EmailTableHeader[] headers) #
Returns: EmailTable

Adds a header to the table using a preconfigured header object.

Parameters

header HtmlForgeX.Email.EmailTableHeader requiredposition: 0
AddHeader(HtmlForgeX.Email.EmailTableHeader[] headers) #

Adds multiple headers to the table using preconfigured header objects.

Parameters

headers HtmlForgeX.Email.EmailTableHeader[] required
AddHeader(System.String text, HtmlForgeX.Email.Alignment align, System.Int32 colspan) #

Adds a header to the table with strongly-typed alignment.

Parameters

text System.String required
align HtmlForgeX.Email.Alignment required
colspan System.Int32 required
public EmailTable AddHeader(params String[] headers) #
Returns: EmailTable

Adds multiple headers to the table.

Parameters

headers System.String[] requiredposition: 0
The header texts.

Returns

The EmailTable object, allowing for method chaining.

AddRow 2 overloads
public EmailTableRow AddRow(Action<EmailTableRow> config) #
Returns: EmailTableRow

Adds a row to the table.

Parameters

cells System.String[] requiredposition: 0
The cell values for the row.

Returns

The EmailTableRow that was added.

AddRow(System.Action{HtmlForgeX.Email.EmailTableRow} config) #

Adds a row to the table using a configuration action.

Parameters

config System.Action{HtmlForgeX.Email.EmailTableRow} required
The configuration action for the row.

Returns

The EmailTableRow that was added.

public override Void EvaluateLayout(LayoutContext context) #
Returns: Void

Applies default border radius for the table.

Parameters

context HtmlForgeX.Email.LayoutContext requiredposition: 0
Layout evaluation context.
PopulateFromData 2 overloads
public EmailTable PopulateFromData(IEnumerable<IDictionary<String, Object>> data, Boolean transpose = false) #
Returns: EmailTable

Populates the table from a data collection (object version for backwards compatibility).

Type Parameters

T

Parameters

data System.Collections.Generic.IEnumerable{System.Object} requiredposition: 0
The data collection to populate from.
transpose System.Boolean = false optionalposition: 1
Whether to transpose rows and columns.

Returns

The EmailTable object, allowing for method chaining.

PopulateFromData(System.Collections.Generic.IEnumerable{System.Collections.Generic.IDictionary{System.String,System.Object}} data, System.Boolean transpose) #

Populates the table from dictionaries.

Parameters

data System.Collections.Generic.IEnumerable{System.Collections.Generic.IDictionary{System.String,System.Object}} required
Collection of dictionaries where keys are headers.
transpose System.Boolean required
Whether to transpose rows and columns.

Returns

The EmailTable object.

PopulateFromData``1(System.Collections.Generic.IEnumerable{``0} data, System.Boolean transpose) #

Populates the table from a data collection.

Type Parameters

T
The type of objects in the data collection.

Parameters

data System.Collections.Generic.IEnumerable{``0} required
The data collection to populate from.
transpose System.Boolean required
Whether to transpose rows and columns.

Returns

The EmailTable object, allowing for method chaining.

RegisterLibraries() #

Registers required libraries for EmailTable.

public override String ToString() #
Returns: String

Converts the EmailTable to its HTML representation.

Returns

HTML string representing the email table.

TransposeInternal() #

Transposes headers and rows.

public EmailTable WithAutoMobileStackedLayout(Boolean enabled = true) #
Returns: EmailTable

Enables/disables automatic mobile stacked layout for wide tables.

Parameters

enabled System.Boolean = true optionalposition: 0
public EmailTable WithAutoMobileStackedMinColumns(Int32 columns) #
Returns: EmailTable

Sets the minimum column count required to auto-enable stacked layout.

Parameters

columns System.Int32 requiredposition: 0
public EmailTable WithBorderRadius(String radius) #
Returns: EmailTable

Sets the border radius for the table.

Parameters

radius System.String requiredposition: 0
CSS radius value.

Returns

The table instance.

public EmailTable WithBorders(Boolean include = true, String color = "#e2e8f0") #
Returns: EmailTable

Sets the table borders (fluent API).

Parameters

include System.Boolean = true optionalposition: 0
Whether to include borders.
color System.String = "#e2e8f0" optionalposition: 1
The border color.

Returns

The EmailTable object, allowing for method chaining.

public EmailTable WithCellPadding(EmailTablePadding padding) #
Returns: EmailTable

Sets the cell padding using semantic values.

Parameters

padding HtmlForgeX.Email.EmailTablePadding requiredposition: 0
The padding level to apply.

Returns

The EmailTable object, allowing for method chaining.

public EmailTable WithConditionalFormatting(Action<EmailTableConditionalFormatting> configure) #
Returns: EmailTable

Configures conditional formatting for the table.

Parameters

configure System.Action{HtmlForgeX.Email.EmailTableConditionalFormatting} requiredposition: 0
Configuration action for conditional formatting.

Returns

The EmailTable object, allowing for method chaining.

public EmailTable WithCustomCellPadding(String padding) #
Returns: EmailTable

Sets custom cell padding values.

Parameters

padding System.String requiredposition: 0
CSS padding string (e.g., "10px 15px").

Returns

The EmailTable object, allowing for method chaining.

public EmailTable WithFixedLayout(Boolean enabled = true) #
Returns: EmailTable

Enables/disables fixed table layout. Fixed layout improves Outlook rendering of long values but can change sizing behavior.

Parameters

enabled System.Boolean = true optionalposition: 0
WithMargin 3 overloads
WithMargin(HtmlForgeX.Email.EmailSpacing spacing) #

Sets the table margin using predefined spacing values.

Parameters

spacing HtmlForgeX.Email.EmailSpacing required
The predefined spacing value for all sides.

Returns

The EmailTable object, allowing for method chaining.

public EmailTable WithMargin(EmailSpacing vertical, EmailSpacing horizontal) #
Returns: EmailTable

Sets the table margin using predefined spacing values for vertical and horizontal.

Parameters

vertical HtmlForgeX.Email.EmailSpacing requiredposition: 0
The predefined vertical spacing (top and bottom).
horizontal HtmlForgeX.Email.EmailSpacing requiredposition: 1
The predefined horizontal spacing (left and right).

Returns

The EmailTable object, allowing for method chaining.

public EmailTable WithMargin(EmailSpacing top, EmailSpacing right, EmailSpacing bottom, EmailSpacing left) #
Returns: EmailTable

Sets the table margin using predefined spacing values for all sides.

Parameters

top HtmlForgeX.Email.EmailSpacing requiredposition: 0
The predefined top spacing.
right HtmlForgeX.Email.EmailSpacing requiredposition: 1
The predefined right spacing.
bottom HtmlForgeX.Email.EmailSpacing requiredposition: 2
The predefined bottom spacing.
left HtmlForgeX.Email.EmailSpacing requiredposition: 3
The predefined left spacing.

Returns

The EmailTable object, allowing for method chaining.

public EmailTable WithMobileStackedBreakpoint(Int32 px) #
Returns: EmailTable

Sets the mobile breakpoint (px) for the stacked layout. Supported values: 480, 560, 600.

Parameters

px System.Int32 requiredposition: 0
public EmailTable WithMobileStackedLabelWidth(String width) #
Returns: EmailTable

Sets the label column width for the stacked mobile layout (e.g. "35%" or "140px").

Parameters

width System.String requiredposition: 0
public EmailTable WithMobileStackedLayout(Boolean enabled = true) #
Returns: EmailTable

Enables/disables the mobile stacked layout for narrow screens.

Parameters

enabled System.Boolean = true optionalposition: 0
public EmailTable WithMobileStackedRowGap(Int32 px) #
Returns: EmailTable

Sets the spacing (px) between label/value rows in the stacked mobile layout.

Parameters

px System.Int32 requiredposition: 0
public EmailTable WithRounded() #
Returns: EmailTable

Applies a medium border radius to the table.

Returns

The table instance.

public EmailTable WithRoundedBorderSpacing(Int32 horizontalSpacing = 16) #
Returns: EmailTable

Enables email-safe spacing for tables with rounded borders. Uses cell-specific padding patterns that work reliably in all email clients.

Parameters

horizontalSpacing System.Int32 = 16 optionalposition: 0
Additional horizontal spacing in pixels (default: 16).

Returns

The EmailTable object, allowing for method chaining.

public virtual EmailTable WithRoundingMode(RoundingMode mode) #
Returns: EmailTable

Sets the rounding mode for this table.

Parameters

mode HtmlForgeX.Email.RoundingMode requiredposition: 0
Rounding mode.

Returns

The table instance.

public EmailTable WithStriped(Boolean striped = true, String color = "#f1f5f9") #
Returns: EmailTable

Sets striped rows (fluent API).

Parameters

striped System.Boolean = true optionalposition: 0
Whether to stripe rows.
color System.String = "#f1f5f9" optionalposition: 1
The stripe color.

Returns

The EmailTable object, allowing for method chaining.

public EmailTable WithStyle(EmailTableStyle style) #
Returns: EmailTable

Sets the table style with predefined styling (fluent API consistent with other components).

Parameters

style HtmlForgeX.Email.EmailTableStyle requiredposition: 0
The predefined table style.

Returns

The EmailTable object, allowing for method chaining.

public EmailTable WithThemeAwareDefaults(Boolean enabled = true) #
Returns: EmailTable

When enabled, default table colors follow the per-email Theme palette. This keeps tables visually consistent with the rest of the email in light/dark themes.

Parameters

enabled System.Boolean = true optionalposition: 0

Properties

public List<EmailTableHeader> Headers { get; set; } #

Gets or sets the table headers.

public List<EmailTableRow> Rows { get; set; } #

Gets or sets the table rows.

public Boolean IncludeBorders { get; set; } #

Gets or sets whether to include borders.

public String BorderColor { get; set; } #

Gets or sets the border color.

public Boolean StripedRows { get; set; } #

Gets or sets whether to stripe alternate rows.

public String StripeColor { get; set; } #

Gets or sets the stripe color.

public String HeaderStyle { get; set; } #

Gets or sets the header style.

public String CellStyle { get; set; } #

Gets or sets the cell style.

public Boolean ThemeAwareDefaults { get; set; } #

When enabled, default table colors (border/stripe/header/cell text) follow the per-email Theme palette. Custom styles and explicit colors are preserved.

public EmailTableConditionalFormatting ConditionalFormatting { get; set; } #

Gets or sets the conditional formatting rules.

public EmailTablePadding CellPadding { get; set; } #

Gets or sets the padding level for table cells.

public String CustomCellPadding { get; set; } #

Gets or sets custom cell padding (overrides CellPadding enum). Format: "vertical horizontal" (e.g., "10px 15px")

public Boolean UseWrapper { get; set; } #

Gets or sets whether to use a wrapper for better spacing. When true, wraps the table in an additional table with padding.

public Int32 ExtraHorizontalSpacing { get; set; } #

Gets or sets extra horizontal spacing for rounded border tables (email-safe approach). Applied as additional padding to first and last cells in each row.

public String BorderRadius { get; set; } #

Gets or sets the border radius for the table. Default is no rounded corners.

public Boolean UseFixedLayout { get; set; } #

When enabled, uses table-layout: fixed to prevent long cell values from causing overflow/overlap in Outlook. Disable to restore content-driven sizing behavior.

public Boolean UseMobileStackedLayout { get; set; } #

When enabled, renders an alternate stacked layout for narrow screens. The desktop table is hidden on small screens while the stacked version is shown. Note: this doubles the HTML output because both layouts are emitted for CSS-based switching.

public Boolean AutoMobileStackedLayout { get; set; } #

When enabled, automatically switches to stacked layout on mobile for wide tables.

public Int32 AutoMobileStackedLayoutMinColumns { get; set; } #

Minimum column count required to enable auto-stacked layout.

public String MobileStackedLabelWidth { get; set; } #

Label column width for the stacked mobile layout (e.g. "35%" or "140px").

public Int32 MobileStackedBreakpointPx { get; set; } #

Breakpoint (in px) at which the stacked mobile layout is shown. Supported values: 480, 560, 600.

public Int32 MobileStackedRowGapPx { get; set; } #

Extra spacing (px) between stacked label/value rows inside a mobile card.

public virtual RoundingMode RoundingMode { get; set; } #

Controls how rounding is applied when no explicit radius is set.