Skip to content

Format-SpectreTable

Synopsis

Formats an array of objects into a Spectre Console table. Thanks to trackd and fmotion1 for the updates to support markdown and color in the table contents. Example table


Description

This function takes an array of objects and formats them into a table using the Spectre Console library. The table can be customized with a border style and color.


Examples

This example formats an array of objects into a table with a double border and the accent color of the script.

$data = @(
    [pscustomobject]@{Name="John"; Age=25; City="New York"},
    [pscustomobject]@{Name="Jane"; Age=30; City="Los Angeles"}
)
Format-SpectreTable -Data $data

Parameters

Property

The list of properties to select for the table from the input data.

TypeRequiredPositionPipelineInput
[String[]]false1false

Data

The array of objects to be formatted into a table.

TypeRequiredPositionPipelineInput
[Object]truenamedtrue (ByValue)

Border

The border style of the table. Default is “Double”.

Valid Values:

  • Ascii
  • Ascii2
  • AsciiDoubleHead
  • Double
  • DoubleEdge
  • Heavy
  • HeavyEdge
  • HeavyHead
  • Horizontal
  • Markdown
  • Minimal
  • MinimalDoubleHead
  • MinimalHeavyHead
  • None
  • Rounded
  • Simple
  • SimpleHeavy
  • Square
TypeRequiredPositionPipelineInput
[String]falsenamedfalse

Color

The color of the table border. Default is the accent color of the script.

TypeRequiredPositionPipelineInput
[String]falsenamedfalse

Width

The width of the table.

TypeRequiredPositionPipelineInput
[Int32]falsenamedfalse

HideHeaders

Hides the headers of the table.

TypeRequiredPositionPipelineInput
[Switch]falsenamedfalse

Title

The title of the table.

TypeRequiredPositionPipelineInput
[String]falsenamedfalse

AllowMarkup

Allow Spectre markup in the table elements e.g. [green]message[/].

TypeRequiredPositionPipelineInput
[Switch]falsenamedfalse

Syntax

Format-SpectreTable [[-Property] <String[]>] -Data <Object> [-Border <String>] [-Color <String>] [-Width <Int32>] [-HideHeaders] [-Title <String>] [-AllowMarkup] [<CommonParameters>]