Search code examples
phpphpexcelxls

Not able to set border to a column - phpexcel


I am using PhpExcel for my application. When I use this below code to set border for an individual cell, it works fine. But when I use it for all cells in a column ('A') it throws the below error:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 24 bytes) in C:\xampp\htdocs\rat\xls-class\PHPExcel\Worksheet.php on line 1219

Defining border style:

$border_style= array('borders' => array('right' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));

Applying to all cells in column 'A':

$sheet->getStyle("A")->applyFromArray($border_style);

Solution

  • You can't apply a style to a column, only to an individual cell or to a range of cells

    $sheet->getStyle("A1:A65535")->applyFromArray($border_style);