spectreconsole/spectre.console · error · InvalidOperationException

Column spanning is not supported in table footer rows.

Error message

Column spanning is not supported in table footer rows.

What it means

The TableColumn.Footer setter, like Header, forbids column-spanning cells. Assigning a TableCell whose ColumnSpan > 1 to Footer throws InvalidOperationException. Spanning is permitted only in body rows; footer layout cannot merge columns.

Source

Thrown at src/Spectre.Console/Widgets/Table/TableColumn.cs:38

            {
                throw new InvalidOperationException("Column spanning is not supported in table header rows.");
            }

            _header = value ?? throw new ArgumentNullException(nameof(value));
        }
    }

    /// <summary>
    /// Gets or sets the column footer.
    /// </summary>
    public IRenderable? Footer
    {
        get => _footer;
        set
        {
            if (value is TableCell cell && cell.ColumnSpan > 1)
            {
                throw new InvalidOperationException("Column spanning is not supported in table footer rows.");
            }

            _footer = value;
        }
    }

    /// <summary>
    /// Gets or sets the width of the column.
    /// If <c>null</c>, the column will adapt to its contents.
    /// </summary>
    public int? Width { get; set; }

    /// <summary>
    /// Gets or sets the padding of the column.
    /// Vertical padding (top and bottom) is ignored.
    /// </summary>
    public Padding? Padding { get; set; }

View on GitHub (pinned to 0acc92fada)

Solutions

  1. Assign a plain renderable (new Markup(text)) to Footer, not a spanned TableCell.
  2. Create a separate non-spanning cell instance for the footer rather than reusing a body cell.
  3. If a merged footer is required, render it as a separate table/caption outside the footer row.

Example fix

// before
column.Footer = new TableCell("Total").Span(2);

// after
column.Footer = new Markup("Total");
Defensive patterns

Strategy: validation

Validate before calling

var footerCell = value as TableCell;
if (footerCell is not null && footerCell.ColumnSpan > 1)
    throw new InvalidOperationException("Footers cannot span columns.");
column.Footer = value;

Type guard

static bool IsSafeFooter(IRenderable r) => r is not TableCell tc || tc.ColumnSpan <= 1;

Prevention

When it happens

Trigger: Setting column.Footer = new TableCell(text).Span(2); reusing a spanning body TableCell as a footer; constructing footers via a shared cell factory that applies spans.

Common situations: Wanting a 'Total' footer that spans several columns (unsupported); reusing a body TableCell for the footer row; assuming Footer follows the same rules as body rows.

Related errors


AI-assisted analysis of spectreconsole/spectre.console@0acc92fada (2026-08-13). Data as JSON: /api/errors/fc3cd353432c341b. Report an issue: GitHub.