How to give background color to entire sheet in php_writeExcel

2k views Asked by At

I am using php_writeExcel module for export data to an Excel File. I want to set background color as "White" to entire Sheet. Also Border color is White. Is there any function using which I can set White color as background color for worksheet?

Thank you!!

1

There are 1 answers

2
PravyNandas On

One closest solution I can give you is setting background color for the utilized range of the sheet (if you're data is within the vicinity of the sheet, increase the range to something like 'A1:Z100', but beware it's memory intense act)

$usedRange = $objPHPExcel->getActiveSheet(0)->calculateWorksheetDimension();
//For used data range
//$usedRange = $objPHPExcel->getActiveSheet(0)->calculateWorksheetDataDimension();
$objPHPExcel->getActiveSheet(0)->getStyle($usedRange)->applyFromArray(
    array('fill'    => array(
                                'type'      => PHPExcel_Style_Fill::FILL_SOLID,
                                'color'     => array('argb' => 'FFFFFFFF')
                            ),
         )
    );

I believe there are certain limitations when it comes to accessing entire sheet. Unlike in Excel VBA following statement may not even execute since it's swallow all your server memory which hardly takes microseconds in excel macro.

ActiveSheet.Range("A1:IV65536").Interior.ColorIndex = 13