Closed REJack closed 3 years ago
hi @REJack version 3.1.5 has just released and support it, now you can use .WithHeaderTextAlignment(...)
This is demo code:
ConsoleTableBuilder
.From(SampleTableData())
.WithFormat(ConsoleTableBuilderFormat.Alternative)
.WithColumnFormatter(1, (text) => $"[ {text.ToUpper()} ]")
.WithFormatter(1, (text) => $"<{text}>")
.WithMinLength(new Dictionary<int, int> {
{ 1, 30 } // increase column width to look easier
})
.WithTextAlignment(new Dictionary<int, TextAligntment>{
{ 1, TextAligntment.Right } // align text of 2nd column to Right
})
.WithHeaderTextAlignment(new Dictionary<int, TextAligntment> {
{1, TextAligntment.Center } // alight header text of 2nd column to Center
})
.WithTitle("MY TABLE", ConsoleColor.DarkRed, ConsoleColor.Gray, TextAligntment.Right)
.ExportAndWriteLine(TableAligntment.Center);
static DataTable SampleTableData()
{
DataTable table = new DataTable();
table.Columns.Add("Name", typeof(string));
table.Columns.Add("Position", typeof(string));
table.Columns.Add("Office", typeof(string));
table.Columns.Add("Age", typeof(int));
table.Columns.Add("Start Date", typeof(DateTime));
table.Rows.Add("Airi Satou", "Accountant", "Tokyo", 33, new DateTime(2017, 05, 09));
table.Rows.Add("Angelica Ramos", "Chief Executive Officer (CEO)", "New York", 47, new DateTime(2017, 01, 12));
table.Rows.Add("Ashton Cox", "Junior Technical Author", "London", 46, new DateTime(2017, 04, 02));
table.Rows.Add("Bradley Greer", "Software Engineer", "San Francisco", 28, new DateTime(2017, 11, 15));
return table;
}
Screenshot
Sweet 😄 thx for the demo code, I will adapt it.
Thx for your amazing library 😍
It is possible to align the header in center but align the content rows to the left?
Actual behavior:
Ideal behavior:
P.S. The images are demo images created fast in VSCode 🤣
regards REJack