Format multiple cells at once

Topics: Developer Forum, User Forum
Jun 11, 2010 at 6:01 PM

I have the following code, which works perfect:


which works like a charm (sets the font to bold for all values in row 1 of columns A through U. However, this code:


does not autosize columns A through U, only A. In order to achieve this I need to do the following:

for ($col = 'A'; $col != 'V'; $col++) {


OR, I need to specify the setAutoSize(true) for each column.


Am I missing something here or is this by design? Why would a range work for one feature but not another?

Jun 26, 2010 at 9:59 AM
Edited Jun 26, 2010 at 10:02 AM

I reviewed the source code and indeed it seems that you cannot set the autosize on a range of columns.

However, you can apply one of the following workaround:

1. Change the default autosize to "true"(in Worksheet\ColumnDimension.php) as this is set to false in the constructor

2. Apply the autosize to a range of columns by providing the columns number. For your case, to set the autosize for A:U you could do something like:



Hope it works.