Skip to content

Print out a nicely formatted table in a console application C#

License

Notifications You must be signed in to change notification settings

soryu-ryouji/TerminalTables

Repository files navigation

Terminal Table

Print Data as table to Terminal

Example usage

var table = new Table("Name", "Age", "Gender");
table.AddRow("Ryouji", "43", "Male");
table.AddRow("Rei", "16", "Female");
var str = table.Export(cellWidth: 20);
Console.WriteLine(str);

Console.WriteLine();

var table2 = new Table("Command", "Description");
var row = new List<TableCell>()
{
    new("add"),
    new([
        "Add some text to array",
        "",
        "Add some number to array"
    ])
};
table2.AddRow(row);
var str2 = table2.Export(cellWidth: 25);
Console.WriteLine(str2);
Console.WriteLine();
var str3 = table2.Export(cellWidth: 20);
Console.WriteLine(str3);

Console output

Name                  Age                   Gender                
Ryouji                43                    Male                  
Rei                   16                    Female                


Command                    Description                
add                        Add some text to array     
                                                      
                           Add some number to array   


Command               Description           
add                   Add some text to arr  
                      ay                    
                                            
                      Add some number to a  
                      rray                  

About

Print out a nicely formatted table in a console application C#

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages