How to freeze headers and a set of columns using PHPExcel

You can only have one single freezePane on any individual worksheet, so you set the address to cover both horizontal and vertical, e.g.

$sheet->freezePane( "D2" );

Freeze fourth column and first line :

$sheet = $spreadsheet->getActiveSheet(); //get current active sheet (first sheet)

$sheet->freezePane('D2');

And if you want to Freeze first column and first line:

$sheet->freezePane('B2');

Freeze first column only:

$sheet->freezePane('B1');

Freeze till second column:

$sheet->freezePane('C1');

Freeze first line(row) Only:

$sheet->freezePane('A2');

Freeze til second line(row):

$sheet->freezePane('A3');

Tags:

Php

Phpexcel