Home >Backend Development >PHP Tutorial >How to freeze (lock) table header in PHPExcel

How to freeze (lock) table header in PHPExcel

黄舟
黄舟Original
2017-09-15 09:26:083067browse

PHPExcel method to freeze (lock) the header: first create a PHPExcel object; then use [setActiveSheetIndex(0)] and [getActiveSheet()->freezePane('A2')] to freeze the cells .

How to freeze (lock) table header in PHPExcel

How to freeze (lock) the table header in PHPExcel?

The example in this article describes the simple implementation method of freezing (locking) the table header in PHPExcel. Share it with everyone for your reference, the details are as follows:

PHPExcel is a relatively powerful PHP plug-in for operating Microsoft excel. In order to facilitate viewing when exporting data, sometimes it is necessary to lock the table header, that is, scrolling to view When reading data, the header always appears in the field of view and will not disappear.

The calling method is as follows:

$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->freezePane('A2');

The above code is to freeze the first row of the table. You may have some doubts about this method. Why is it to freeze the first row? The following picture explains it Principle

The picture is a bit ugly, as long as everyone can understand it

For more related knowledge, please visit PHP Chinese website ! !

The above is the detailed content of How to freeze (lock) table header in PHPExcel. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn