Open dmoonfire opened 2 years ago
Not sure I understand your question, are you asking about 2 bellow char
you can set column padding (space left and right of column) using WithPaddingLeft
and WithPaddingRight
another option I think you can config Header Char Map for TopLeft
, `BorderLeft,
BottomLeftand
TopRight,
BorderRight, and
BottomRightto empty string using
.WithHeaderCharMapDefinition`
Thank you, that covers one of the two questions. The other is the space divider between columns without having padding. In a unit test, this is what I expected would work but didn't.
[Test]
public void DefaultFormatWithDataTable()
{
var strBuilder =
ConsoleTableBuilder
.From(SampleData.SampleTableData)
.WithPaddingLeft(string.Empty)
.WithPaddingRight(string.Empty)
.WithCharMapDefinition(
new Dictionary<CharMapPositions, char>
{
{ CharMapPositions.DividerY, ' ' },
})
.WithHeaderCharMapDefinition(
new Dictionary<HeaderCharMapPositions, char>
{
{ HeaderCharMapPositions.BottomCenter, ' ' },
{ HeaderCharMapPositions.Divider, ' ' },
{ HeaderCharMapPositions.BorderBottom, '-' },
});
.Export();
Assert.IsTrue(strBuilder.ToString() == @"Name Position Office Age Start Date
-------------- ----------------------------- ------------- --- ---------------------
Airi Satou Accountant Tokyo 33 5/9/2017 12:00:00 AM
Angelica Ramos Chief Executive Officer (CEO) New York 47 1/12/2017 12:00:00 AM
Ashton Cox Junior Technical Author London 46 4/2/2017 12:00:00 AM
Bradley Greer Software Engineer San Francisco 28 11/15/2017 12:00:00 AM
");
var lines = strBuilder.ToString().Split('\n');
Assert.IsTrue(lines.Length == 7);
}
It appears that when I have this:
{ HeaderCharMapPositions.BottomCenter, ' ' },
{ HeaderCharMapPositions.Divider, ' ' },
It collapses the divider space entirely instead of giving me a blank line. So I get this divider:
--------------------------------------------------------------------------------
If I change the above BottomCenter to '+'
, I still get the divider space:
--------------+-----------------------------+-------------+---+---------------------
I would like to know how I could get that unit test output (I might be off on the dashes though on the header).
It's because it has fallback from CharMapDefinition
, but char on CharMapDefinition
is empty
I will try to open a toggle to block the fallback
I like the minimal format, except I find the solid bar for the headers to be difficult to parse the columns.
So, I thought I would try to make a version that had spaces in it:
But what I found was if both
BottomCenter
andDivider
are spaces (' '
), then the space is collapsed between the two of them which squishes the columns together. I ended up needing to put something between the two to make it work:This produces a table like this:
Adding that adds extra columns to the right and left of the headers, which isn't ideal but workable. But, being able to have spaces between the columns would be greatly appreciated. Is there a way of doing that?