Skip to content

Release v2.2.0

Latest

Choose a tag to compare

@github-actions github-actions released this 06 Apr 13:52
6357abb

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