Closed KajdeMunter closed 1 year ago
There is an overload that takes an IEnumerable<object>
. So you should be able to. I'm confused I guess. The issue you seem to be running into is that you haven't actually defined your columns.
Yes, but this would require creating a entire new object that fits the table markup, right?
For example I have a class with UserID and a Dictionary that contains an articleID and a Rating. When I add this to the table I get something like this:
Count: 7
--------------------------------------------------------------------------------------
| userId | ratings |
--------------------------------------------------------------------------------------
| 1 | System.Collections.Generic.SortedDictionary`2[System.Int32,System.Single] |
--------------------------------------------------------------------------------------
And something like this:
ConsoleTable.From(new[] {1, 2, 3, 4, 5, 6, 7}).Write();
Does not work, because the columns aren't defined.
And because it is a static method we cannot do something like this:
ConsoleTable table = new ConsoleTable();
table.AddColumn(new[] {"userid", "1", "2", "3"});
table.From(new[] {"1", "3.5", "5.0", "1.1"})
Currently the AddRow function takes
params object[] values
:And afterwards checks the length:
But when we want to add a row from an array like so:
values.Length
will return 1, which will result in the exceptionThe number columns in the row (x) does not match the values (x)
.It would be nice to be able to use an array like in my example so that the table can be filled more dynamically.