Skip to content

Title & Footer Bars #8

Closed
Closed

Description

@Hulkstance

I like the MarkDown format but can you add a title bar and a footer option? You can do it as an extension method to your Builder pattern .WithTitle(...), .WithFooter(...).

ConsoleTableBuilder.From(GenerateResults(results))
   .WithFormat(ConsoleTableBuilderFormat.MarkDown)
   .ExportAndWriteLine();

Example

========== CONTACTS ==========
| Id | First Name | Surname  |
|----------------------------|
| 1  | Isaac      | Asimov   |
| 2  | Robert     | Heinlein |
| 3  | Frank      | Herbert  |
| 4  | Aldous     | Huxley   |
==============================

Activity

  1. minhhungit commented on Jan 30, 2021

    @minhhungit
    Owner

    @Hulkstance That is good idea, I will implement it in next version

  2. minhhungit commented on Jan 30, 2021

    @minhhungit
    Owner

    version 3.0 is released, you can use char map to implement the example

    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 table
    ConsoleTableBuilder
        .From(tableData)
        .ExportAndWriteLine();
    
    
    // Advanced table 
    ConsoleTableBuilder
        .From(tableData)
        .WithTitle("CONTACTS ")
        .WithColumn("Id", "First Name", "Sur Name")
        .WithCharMapDefinition(new Dictionary<CharMapPositions, char> {                   
            {CharMapPositions.BottomLeft, '=' },
            {CharMapPositions.BottomCenter, '=' },
            {CharMapPositions.BottomRight, '=' },
            {CharMapPositions.BorderX, '=' },
            {CharMapPositions.BorderY, '|' },
            {CharMapPositions.DividerY, '|' },
        })
        .WithHeaderCharMapDefinition(new Dictionary<HeaderCharMapPositions, char> {
            {HeaderCharMapPositions.TopLeft, '=' },
            {HeaderCharMapPositions.TopCenter, '=' },
            {HeaderCharMapPositions.TopRight, '=' },
            {HeaderCharMapPositions.BottomLeft, '|' },
            {HeaderCharMapPositions.BottomCenter, '-' },
            {HeaderCharMapPositions.BottomRight, '|' },
            {HeaderCharMapPositions.Divider, '|' },
            {HeaderCharMapPositions.BorderXTop, '=' },
            {HeaderCharMapPositions.BorderXBottom, '-' },
            {HeaderCharMapPositions.BorderY, '|' },
        })
        .ExportAndWriteLine();

    image

  3. prodrammer commented on Feb 10, 2021

    @prodrammer

    If I don't have the charmaps, "WithTitle" doesn't work. Is this intentional? It's confusing to have "WithTitle" in the API.

    BTW, just "bought you a coffee". Thanks!

  4. minhhungit commented on Feb 10, 2021

    @minhhungit
    Owner

    Thank you @prodrammer for the coffee, I'm very appreciate
    Yes, WithTitle at this time (ver 3.0) just work for "custom" formats, will support it in next release

  5. minhhungit commented on Feb 12, 2021

    @minhhungit
    Owner

    @Hulkstance @prodrammer version 3.1.2 is released, right now old formats like markdown, alternative... can has title

    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions