PHPExcel Freezepane not working

Topics: Developer Forum
Jun 14, 2013 at 10:21 AM
In my output, i want to freeze first column in the output. i have used below code, but it is not working.
$objPHPExcel->getActiveSheet()->freezePane('A1')
Coordinator
Jun 14, 2013 at 12:27 PM
Edited Jun 14, 2013 at 12:28 PM
You're telling it to freeze rows above row "1" and to the left of column "A".... most spreadsheets don't have any rows above or columns to the left of that cell.


Try
$objPHPExcel->getActiveSheet()->freezePane('B2');
which tells Excel to freeze rows above row 2, and to the left of column "B"... i.e. row 1 and column "A".
Jun 15, 2013 at 8:07 AM
for ($char = 'A'; $char <= 'Z'; $char++) {
  $objPHPExcel->getActiveSheet()->setCellValue($char.'5','40');
}
for ($i=1;$i<=100;$i++){
    $objPHPExcel->getActiveSheet()->setCellValue('A'.$i,generateRandomString());
}
$objPHPExcel->getActiveSheet()->freezePane('B');
// Write the PHPExcel object to browser as HTML
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
$objWriter->save('php://output');
$objPHPExcel->getActiveSheet()->freezePane('B');
Freeze not happened for the " A " (First column) column.
Attached screen shot FYI.

Image

Freeze not happened for the " A " (First column) column.
When i scroll COL A not freeze, col A also hidding.

Image
Coordinator
Jun 15, 2013 at 9:15 AM
Edited Jun 15, 2013 at 9:16 AM
No it won't.... you need to give a cell reference, not a row number or a column ID
$objPHPExcel->getActiveSheet()->freezePane('B1');
But freeze panes is an Excel feature, and works with the Excel5 and Excel2007 Writers, not with the HTML Writer
Jun 15, 2013 at 11:06 AM
Edited Jun 15, 2013 at 11:07 AM
awesome, this what i am expecting from gurus, i am exporting excel information in to WEB View (HTML),

in Excel (xls) freeze working fine, but this freeze is not working in HTML.

So as per you reply, freeze functionality will not work for HTML Writer. (ie. WEB Display)

Thanks to @MarkBaker

Thanks
Bharani
Jun 15, 2013 at 11:18 AM
Then how google handling this feature in google spreadsheet. Image

please chk attached screenshot.

Is there any open source library available in PHP.
Coordinator
Jun 15, 2013 at 11:37 AM
bharanikumariyer wrote:
Then how google handling this feature in google spreadsheet.
I've no idea how Google handles freeze pane.
Is there any open source library available in PHP.
You might not have noticed, but PHPExcel is open source: when you download it, you download the source code, under an LGPL license, which means you can modify it as well; and the latest source is always available in the github repository.

And there's nothing to stop you looking at the code for the HTML Writer and adding the facility to freeze pane in that.