Column style

A ColumnStyle let us change the width of a column. Each column has its own ColumnStyle object, which can be retrieved using the method getColumnStyle($columnIndex) of the class Table.

$table = new Table('table1');
//create columns and add rows
//...
$columnStyle1 = $table->getColumnStyle(0);
$columnStyle1->setWidth('2cm');

If you try this example, you won't see any changes. That's because we need to do other things, like setting the width of the whole table, and also setting the alignment of the table. We'll see that in the next tutorials.