DEV Community

Cover image for FluentTextTable, "full-width supported" text table library for .NET is now available!
Atsushi Nakamura
Atsushi Nakamura

Posted on

FluentTextTable, "full-width supported" text table library for .NET is now available!

Have you ever just wanted to output .NET object out to console?

What's this?

FluentTextTable is a flexible and easy to use "full-width supported" text table library for .NET.

var users = new[]
{
    new User {Id = 1, EnglishName = "Bill Gates", JapaneseName = "ビル・ゲイツ", Birthday = DateTime.Parse("1955/10/28")},
    new User {Id = 2, EnglishName = "Steven Jobs", JapaneseName = "スティーブ・ジョブズ", Birthday = DateTime.Parse("1955/2/24")}
};
Build
    .TextTable<User>()
    .WriteLine(users);

Alt Text

It can be used for debugging and simple tools.

Format complex tables with ease and fluently.

Build
    .TextTable<User>(builder =>
    {
        builder
            .Borders.Horizontals.AllStylesAs("-")
            .Borders.HeaderHorizontal.AllStylesAs("=")
            .Columns.Add(x => x.Id).HorizontalAlignmentAs(HorizontalAlignment.Right)
            .Columns.Add(x => x.Name).VerticalAlignmentAs(VerticalAlignment.Center)
            .Columns.Add(x => x.Birthday).VerticalAlignmentAs(VerticalAlignment.Bottom).FormatAs("{0:yyyy/MM/dd}")
            .Columns.Add(x => x.Occupations).FormatAs("- {0}");
    })
    .WriteLine(users);

Alt Text

And this supports markdowns as well.

Build
    .MarkdownTable<User>()
    .WriteLine(users);

Alt Text

Quick Start

NET Framework 4.0 (or higher) and .NET Standard 2.0 (or higher) are supported. Install and use it from NuGet.

> Install-Package FluentTextTable

Define the class to be output.

public class User
{
    public int Id { get; set; }
    public string EnglishName { get; set; }
    public string JapaneseName { get; set; }
    public DateTime Birthday;
}

Use the Build class to create a table for the output class.

By default, all public properties and fields are included in the output.

var table = Build.TextTable<User>();

Create and output an object corresponding to a row.

var users = new[]
{
    new User {Id = 1, EnglishName = "Bill Gates", JapaneseName = "ビル・ゲイツ", Birthday = DateTime.Parse("1955/10/28")},
    new User {Id = 2, EnglishName = "Steven Jobs", JapaneseName = "スティーブ・ジョブズ", Birthday = DateTime.Parse("1955/2/24")}
};
Build
    .TextTable<User>()
    .WriteLine(users);

Detailed settings

See the Github documentation.

https://github.com/nuitsjp/FluentTextTable#table-of-contents

Thank you!

Latest comments (0)