Reputation: 1604
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);
Upvotes: 0
Views: 2229
Reputation: 326
You can apply a border on cells or cell range, for example the following code worked for me well:
public static function afterSheet(AfterSheet $event)
{
$sheet = $event->sheet->getDelegate();
$sheet->getStyle('A4:Z5')->applyFromArray([
'borders' => [
'allBorders' => [
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
'color' => ['argb' => '000000'],
],
],
]);
}
Just implement the function in your export class.
Upvotes: 0
Reputation: 212402
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);
Upvotes: 1