Output Formats

ConsoleTables can render tables in several different styles. You can select a format by passing a Format enum value to the Write() method.

// Example setup for all formats
var table = new ConsoleTable("one", "two", "three");
table.AddRow(1, 2, 3)
     .AddRow("this line should be longer", "yes it is", "oh");

Default Format

Format.Default is the standard format, featuring hyphens for dividers.

table.Write(Format.Default);

Output:

 -------------------------------------------------- 
 | one                        | two       | three |
 -------------------------------------------------- 
 | 1                          | 2         | 3     |
 -------------------------------------------------- 
 | this line should be longer | yes it is | oh    |
 -------------------------------------------------- 

 Count: 2

You can also get this format as a string using table.ToString().

Alternative Format

Format.Alternative uses a different border style with + characters at the intersections, similar to some SQL client outputs.

table.Write(Format.Alternative);

Output:

+----------------------------+-----------+-------+
| one                        | two       | three |
+----------------------------+-----------+-------+
| 1                          | 2         | 3     |
+----------------------------+-----------+-------+
| this line should be longer | yes it is | oh    |
+----------------------------+-----------+-------+

You can get this format as a string using table.ToStringAlternative().

Minimal Format

Format.Minimal provides a clean, borderless look with only a line separating the header from the rows.

table.Write(Format.Minimal);

Output:

one                         two        three 
---------------------------------------------
1                           2          3     
this line should be longer  yes it is  oh    

You can get this format as a string using table.ToMinimalString().

Markdown Format

Format.MarkDown generates a GitHub-Flavored Markdown table. This is perfect for generating documentation or reports programmatically.

table.Write(Format.MarkDown);

Output:

| one                        | two       | three |
|----------------------------|-----------|-------|
| 1                          | 2         | 3     |
| this line should be longer | yes it is | oh    |

You can get this format as a string using table.ToMarkDownString().