Open hron84 opened 3 years ago
Yeah, had to use for each column something like this to limit length of it:
->addColumn(mb_strimwidth($data[1], 0, 39, "..."))
->addColumn($data[2])
->addColumn(mb_strimwidth($data[3], 0, 30, "..."))
->addColumn(mb_strimwidth($data[4], 0, 22, "..."))
Thanks @Faq I will check it soon. Is there any way to specify the width of the column?
As I know, no.
@hron84 Do you persist in seeing the issue? I can see the correct auto-resize when I tried to reproduce it.
@hron84 here:
You must use addHeader() and addColumn() like this:
$table = new \LucidFrame\Console\ConsoleTable();
$header = ['ID', 'Name', 'Key', 'Status', 'Page count', '-'];
$rows = [
[12345689, 'Kategória szövege sok-sok betű', 'CK', 12365478, 'global', 'CURRENT']
];
foreach ($header as $column) {
if (reset($header) === $column) {
$table->addHeader($column);
} else {
$table->addColumn($column);
}
}
foreach ($rows as $row) {
$table->addRow();
foreach ($row as $column) {
$table->addColumn($column);
}
}
$table->display();
and the result will look like this:
+----------+--------------------------------+-----+----------+------------+---------+
| ID | Name | Key | Status | Page count | - |
+----------+--------------------------------+-----+----------+------------+---------+
| 12345689 | Kategória szövege sok-sok betű | CK | 12365478 | global | CURRENT |
+----------+--------------------------------+-----+----------+------------+---------+
Actual behavior
As you see, the header fixes to the size of the header string and does not autosize to the content. It contains utf8 characters but I had an issue with strings without multibyte characters, but even if it would handle multibyte strings badly the name column should wider than 5 chars.
Code:
phplucidframe/console-table dev-master a973d91 Console Table