Setting color values for a column

Nov 25, 2008 at 3:04 PM
Is it possible to set the fill color for an entire column?  I tried setting the color using the getDefaultStyle for the entire worksheet, but that doesn't seem to be valid. 

Thank you.
Developer
Nov 25, 2008 at 3:08 PM
I'm afraid this isn't yet possible. See this work item:

http://www.codeplex.com/PHPExcel/WorkItem/View.aspx?WorkItemId=7333

Nov 25, 2008 at 3:11 PM
Is there an alternate method to doing that?  Can a color be applied to the entire sheet or does it have to be applied to each cell?

Thank you
Developer
Nov 25, 2008 at 4:01 PM
There is not any really good alternative for this. In theory you could apply the style to all the cells in the column, and the spreadsheet would look the same on screen. But it is not the same. When you style cells individually they count as non-empty, but when you style the entire column, it counts as empty and will not force the printer to write tons of blank pages. Therefore we would need the feature from that link I posted.

I recommend that you style your column giving only the non-empty cells a background color. For example, styling column 'A', rows 1 through 200:

$sheet->duplicateStyleArray(
    array(
        'fill' => array(
            'type' => PHPExcel_Style_Fill::FILL_SOLID,
            'startcolor' => array(
                'rgb' => 'FFDD00',
            ),
        ),
    ),
    'A1:A200'
);

That is probably the best you can do for now.



Nov 25, 2008 at 4:07 PM
Thank you.  I can work with that for now.