@@ -76,7 +76,19 @@ method to set the column widths explicitly::
7676
7777In this example, the first column width will be ``10 ``, the last column width
7878will be ``30 `` and the second column width will be calculated automatically
79- because of the ``0 `` value. The output of this command will be:
79+ because of the ``0 `` value.
80+
81+ You can also set the width individually for each column with the
82+ :method: `Symfony\\ Component\\ Console\\ Helper\\ Table::setColumnWidth ` method.
83+ Its first argument is the column index (starting from ``0 ``) and the second
84+ argument is the column width::
85+
86+ // ...
87+ $table->setColumnWidth(0, 10);
88+ $table->setColumnWidth(2, 30);
89+ $table->render();
90+
91+ The output of this command will be:
8092
8193.. code-block :: terminal
8294
@@ -95,16 +107,30 @@ widths. If the contents don't fit, the given column width is increased up to the
95107longest content length. That's why in the previous example the first column has
96108a ``13 `` character length although the user defined ``10 `` as its width.
97109
98- You can also set the width individually for each column with the
99- :method: `Symfony\\ Component\\ Console\\ Helper\\ Table::setColumnWidth ` method.
100- Its first argument is the column index (starting from ``0 ``) and the second
101- argument is the column width::
110+ If you prefer to wrap long contents in multiple rows, use the
111+ :method: `Symfony\\ Component\\ Console\\ Helper\\ Table::setColumnMaxWidth ` method::
102112
103113 // ...
104- $table->setColumnWidth (0, 10 );
105- $table->setColumnWidth(2, 30 );
114+ $table->setColumnMaxWidth (0, 5 );
115+ $table->setColumnMaxWidth(1, 10 );
106116 $table->render();
107117
118+ The output of this command will be:
119+
120+ .. code-block :: terminal
121+
122+ +-------+------------+--------------------------------+
123+ | ISBN | Title | Author |
124+ +-------+------------+--------------------------------+
125+ | 99921 | Divine Com | Dante Alighieri |
126+ | -58-1 | edy | |
127+ | 0-7 | | |
128+ | (the rest of rows...) |
129+ +-------+------------+--------------------------------+
130+
131+ .. versionadded :: 4.2
132+ The ``setColumnMaxWidth() `` method was introduced in Symfony 4.2.
133+
108134The table style can be changed to any built-in styles via
109135:method: `Symfony\\ Component\\ Console\\ Helper\\ Table::setStyle `::
110136
0 commit comments