Releases: BrunoVT1992/ConsoleTable
Releases · BrunoVT1992/ConsoleTable
Release v2.2.0
V2.2.0
Multi-line support
Cell content can contain newlines and the table will adjust row height accordingly, in headers, rows and footers.
Bug fix
- Edge case drawing issues of cell borders miss alligned when having empty rows or empty cell content fixed
- Performance improvements
using ConsoleTable.Text;
// Setup the table
var table = new Table
{
RowTextAlignmentRight = false,
HeaderTextAlignmentRight = false,
FooterTextAlignmentRight = false,
Padding = 2,
Headers = new string[] { "Name", $"Age{Environment.NewLine}&{Environment.NewLine}Birthyear", "City" },
Rows = new List<string[]>
{
new string[] { "Alice Cooper", $"30{Environment.NewLine}1995", "New York" },
new string[] { "Bob", $"25{Environment.NewLine}2000", "Los Angeles" },
new string[] { "Charlie Brown", $"67{Environment.NewLine}1958", "Chicago" },
new string[] { "Gloria", $"40{Environment.NewLine}1985", $"Chicago{Environment.NewLine}Originally from Bogota, Colombia" }
},
Footers = new string[] { $"Total: 4{Environment.NewLine}3 Male - 1 Female", "Total Age: 162" }
};
// Display the table
Console.WriteLine(table.ToTable());Output:
┌─────────────────────┬──────────────────┬────────────────────────────────────┐
│ Name │ Age │ City │
│ │ & │ │
│ │ Birthyear │ │
├═════════════════════┼══════════════════┼════════════════════════════════════┤
│ Alice Cooper │ 30 │ New York │
│ │ 1995 │ │
├─────────────────────┼──────────────────┼────────────────────────────────────┤
│ Bob │ 25 │ Los Angeles │
│ │ 2000 │ │
├─────────────────────┼──────────────────┼────────────────────────────────────┤
│ Charlie Brown │ 67 │ Chicago │
│ │ 1958 │ │
├─────────────────────┼──────────────────┼────────────────────────────────────┤
│ Gloria │ 40 │ Chicago │
│ │ 1985 │ Originally from Bogota, Colombia │
└─────────────────────┴──────────────────┴────────────────────────────────────┘
Total: 4 Total Age: 162
3 Male - 1 Female
Release v2.1.0
V2.1.0
New Properties
| Property | Type | Default | Description |
|---|---|---|---|
ShowBorders |
bool |
true |
When false, the table is drawn without borders for a more minimalist style |
using ConsoleTable.Text;
// Setup the table
var table = new Table
{
ShowBorders = false
};
// Set headers
table.SetHeaders("Name", "Age", "City");
// Add rows
table.AddRow("Alice Cooper", "30", "New York");
table.AddRows(new string[][]
{
new string[] { "Bob", "25", "Los Angeles" },
new string[] { "Charlie Brown", "47", "Chicago" }
});
// Set footers
table.SetFooters("Total: 3", "Total Age: 102");
// Display the table
Console.WriteLine(table.ToTable());Output:
Name Age City
Alice Cooper 30 New York
Bob 25 Los Angeles
Charlie Brown 47 Chicago
Total: 3 Total Age: 102
Release v2.0.0
V2.0.0
New Properties
| Property | Type | Default | Description |
|---|---|---|---|
Footers |
string[] |
Array.Empty<string>() |
The table footers. Footers are not required. |
FooterTextAlignmentRight |
bool |
false |
When true, footer text is right-aligned otherwise left aligned |
New Method
| Method | Description |
|---|---|
SetFooters(params string[] footers) |
Sets the table footers. Calling this again will overwrite previous footers. Footers are not required. |
New Styling
- Headers now have a double bottom line to seperate them from the rows.
- Now an option to add footers to the table (optional). These are drawn without borders at the bottom.
- Footer text can be left or right aligned.
using ConsoleTable.Text;
// Setup the table
var table = new Table();
// Set headers
table.SetHeaders("Name", "Age", "City");
// Add rows
table.AddRow("Alice Cooper", "30", "New York");
table.AddRows(new string[][]
{
new string[] { "Bob", "25", "Los Angeles" },
new string[] { "Charlie Brown", "47", "Chicago" }
});
//Set footers
table.SetFooters("Total: 3", "Total Age: 102");
// Display the table
Console.WriteLine(table.ToTable());Output:
┌───────────────┬────────────────┬─────────────┐
│ Name │ Age │ City │
├═══════════════┼════════════════┼═════════════┤
│ Alice Cooper │ 30 │ New York │
├───────────────┼────────────────┼─────────────┤
│ Bob │ 25 │ Los Angeles │
├───────────────┼────────────────┼─────────────┤
│ Charlie Brown │ 47 │ Chicago │
└───────────────┴────────────────┴─────────────┘
Total: 3 Total Age: 102
Performance Improvements
- Slightly improved performance when rendering large tables with many rows and columns.
Release v1.0.3
V1.0.3
New Property
| Property | Type | Default | Description |
|---|---|---|---|
CachingEnabled |
bool |
true |
When true, the generated table string is cached when the ToTable method is called. Cache will be cleared on any property change or method call. |
New Method
| Method | Description |
|---|---|
ClearCache() |
Clears the cached generated table string. |
Release v1.0.2
V1.0.2
New Properties
| Property | Type | Default | Description |
|---|---|---|---|
Headers |
string[] |
Array.Empty<string>() |
The table headers. Headers are not required. |
Rows |
List<string[]> |
new List<string[]>() |
All the data rows for the table. Rows are not required. |
New Method
| Method | Description |
|---|---|
AddRows(params string[][] rows) |
Adds multiple data rows to the table. Rows are not required. |
Release v1.0.1
V1.0.1
Add support for .net frameworks:
- netstandard2.0
- netcoreapp3.1
- net5.0
- net6.0
- net7.0
- net8.0
- net9.0
- net10.0
Release v1.0.0
V1.0.0
Initial release.