Closed franklupo closed 5 years ago
That can probably be done!
I'm super busy for the next few days, if I forget about this please feel free to ping me again.
We'd also like to right align numbers. Please do add this feature!
Oh hey, I completely forgot about this!
For now alignment will be on a per-column basis, and will pad based on the max column width. Meaning if the column width is the same as number of characters in that row, they won't appear right-aligned. I might as well throw in center-align while I'm at it as well.
Thoughts?
Yes, that sounds perfect. The right align requirement is purely for number presentation, so a column that entirely consisted of 4-digit numbers would be tightly packed, and that's as it should be. However, throw a single 5-digit number into the same column and the alignment would still make sense.
As for center alignment, you're right(-aligned) - might as well throw it in!
@davidnmbond @franklupo I have added support for aligning both the headers and the rows to Left
, Right
, or Center
. This is available under the 1.1.0
nuget package that still indexing.
Please refer to the Readme for code examples.
Hi, the table.AddColumn(...) not working with align but in constructor yes.
Best regards
@franklupo Can you paste a brief repro?
This is working for me:
Table table = new Table("Left");
table.AddColumn("Left Header", Alignment.Right)
.AddColumn("Right Header", Alignment.Center, Alignment.Right)
.AddRow("1", "2", "3")
.AddRow("Short", "item", "Here")
.AddRow("Longer items go here", "Right Contents", "Centered Contents")
.Config = TableConfiguration.MySqlSimple();
Console.Write(table.ToString());
Hi, wonderful job. Is it possible to specify in ToString if the column is aligned to the right?
Best regards