ConsoleTableExt 3.3.0

ConsoleTableExt Build status

A library to print out a nicely formatted table in a console application C#

Nuget

https://www.nuget.org/packages/ConsoleTableExt/

Feature

  • Support box-drawing characters
  • Table alignment (left right and center)
  • Column alignment (left/right/center)
  • Table can have TITLE, can change text color and background color of title, support title alignment (left/right/center)
  • Support power char-map, strong customization ability
  • Contain some popular formas like Markdown table...
  • Support text formatter (include header)
  • Support many kind data type: DataTable, List...
  • Support metadata row (placed at top or bottom of table)
  • Column min-length
  • support .NET Framework >= 3.5, .NET core
  • ...
  • How to use:

    var tableData = new List<List<object>>
    {
        new List<object>{ "Sakura Yamamoto", "Support Engineer", "London", 46},
        new List<object>{ "Serge Baldwin", "Data Coordinator", "San Francisco", 28, "something else" },
        new List<object>{ "Shad Decker", "Regional Director", "Edinburgh"},
    };
    

    Simple example with default format:

    ConsoleTableBuilder
        .From(tableData)
        .ExportAndWriteLine();
    

    More example with existing format Alternative:

    ConsoleTableBuilder
        .From(tableData)
        .WithFormat(ConsoleTableBuilderFormat.Alternative)
        .ExportAndWriteLine(TableAligntment.Center);
    

    Advance example with custom format using CharMap:

    ConsoleTableBuilder
        .From(tableData)
        .WithTitle("CONTACTS ", ConsoleColor.Yellow, ConsoleColor.DarkGray)
        .WithColumn("Id", "First Name", "Sur Name")
        .WithMinLength(new Dictionary<int, int> {
            { 1, 25 },
            { 2, 25 }
        })
        .WithTextAlignment(new Dictionary<int, TextAligntment>
        {
            {2, TextAligntment.Right }
        })
        .WithCharMapDefinition(new Dictionary<CharMapPositions, char> {
            {CharMapPositions.BottomLeft, '=' },
            {CharMapPositions.BottomCenter, '=' },
            {CharMapPositions.BottomRight, '=' },
            {CharMapPositions.BorderTop, '=' },
            {CharMapPositions.BorderBottom, '=' },
            {CharMapPositions.BorderLeft, '|' },
            {CharMapPositions.BorderRight, '|' },
            {CharMapPositions.DividerY, '|' },
        })
        .WithHeaderCharMapDefinition(new Dictionary<HeaderCharMapPositions, char> {
            {HeaderCharMapPositions.TopLeft, '=' },
            {HeaderCharMapPositions.TopCenter, '=' },
            {HeaderCharMapPositions.TopRight, '=' },
            {HeaderCharMapPositions.BottomLeft, '|' },
            {HeaderCharMapPositions.BottomCenter, '-' },
            {HeaderCharMapPositions.BottomRight, '|' },
            {HeaderCharMapPositions.Divider, '|' },
            {HeaderCharMapPositions.BorderTop, '=' },
            {HeaderCharMapPositions.BorderBottom, '-' },
            {HeaderCharMapPositions.BorderLeft, '|' },
            {HeaderCharMapPositions.BorderRight, '|' },
        })
        .ExportAndWriteLine(TableAligntment.Right);
    

    Check more demo here https://github.com/minhhungit/ConsoleTableExt/blob/master/Src/ConsoleTableApp/Program.cs

    Char Map Definition

    Header Char Map

    There are many ways to contribute to ConsoleTableExt, either contribute issue/code directly or buy me a cup of coffee

    Buy Me a Coffee at ko-fi.com

    Inspired by

    No packages depend on ConsoleTableExt.

    workarround issue 42 https://github.com/minhhungit/ConsoleTableExt/issues/42 "Parameter count mismatch" exception when passing lists of strings

    .NET Framework 3.5

    • No dependencies.

    .NET Framework 4.6

    • No dependencies.

    .NET Standard 2.0

    • No dependencies.

    Version Downloads Last updated
    3.3.0 2 12/08/2024
    3.2.0 58 07/22/2022
    3.1.9 2 12/08/2024
    3.1.7 3 12/19/2024
    3.1.6 2 12/09/2024
    3.1.5 3 12/13/2024
    3.1.4 7 05/09/2024
    3.1.3 5 05/13/2024
    3.1.2 4 05/09/2024
    3.0.0 7 05/18/2024
    2.0.3 3 12/19/2024
    2.0.2 5 05/09/2024
    2.0.1 2 12/09/2024
    2.0.0 3 12/03/2024
    1.1.0 5 12/09/2024
    1.0.0 2 12/09/2024
    1.0.0-beta9 3 12/03/2024
    1.0.0-beta19 1 12/08/2024
    1.0.0-beta14 3 12/08/2024
    1.0.0-beta13 6 05/09/2024
    1.0.0-beta10 1 12/07/2024