9

I want to freeze my page headers and columns like so:

enter image description here

I can freeze my headers absolutely fine and dandy:

    $highestRowCount = $sheet->getHighestRow();
    $highestColumnCount = $sheet->getHighestColumn();

    $sheet->freezePane( "{$highestColumnCount}2" );

But when I then add another freeze on the columns:

    $sheet->freezePane( "D{$highestRowCount}" );

It breaks excels ability to scroll...

How might I go about doing this?

Jimmyt1988
  • 20,466
  • 41
  • 133
  • 233

2 Answers2

22

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" );
Mark Baker
  • 209,507
  • 32
  • 346
  • 385
2

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');
Irshad Khan
  • 5,670
  • 2
  • 44
  • 39