php phpexcel冻结行和列
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23423964/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
phpexcel freeze row and columns
提问by CMR
I'm trying to freeze the top row and the first 3 columns in a worksheet, using PHPExcel.
我正在尝试使用 PHPExcel 冻结工作表中的顶行和前 3 列。
I can freeze the row without any problem:
我可以毫无问题地冻结该行:
$objPHPExcel->getActiveSheet()->freezePane('A2');
Or I can freeze the column without any problem:
或者我可以毫无问题地冻结列:
$objPHPExcel->getActiveSheet()->freezePane('D1');
But when I try to use both, the first gets over-written by the second.
但是当我尝试同时使用两者时,第一个会被第二个覆盖。
Is there any way to use both on the same sheet?
有没有办法在同一张纸上同时使用两者?
Thanks.
谢谢。
回答by Tzar
I assume you're trying to Freeze columns and rows both.
我假设您正在尝试冻结列和行。
freezePane
will obviously overwrite any previous parameters you might have given to it.
freezePane
显然会覆盖您可能给它的任何先前参数。
As per your current scenario, I see that you're trying to freeze the top rowand the left-most 3 columns
根据您当前的情况,我看到您正在尝试冻结顶行和最左侧的 3 列
Try this:
尝试这个:
$objPHPExcel->getActiveSheet()->freezePane('D2');
This will freeze Row 1and Columns A,B & C
这将冻结第 1 行和A、B 和 C 列
This should get your work done!
这应该可以完成您的工作!
Note:freezePane
works exactly how you use it in MS Excel. You select a cell and select Freeze. And it freezes whatever rows are above it, and the columns which are left to it.
注意:与您在 MS Excel 中使用它的方式完全相同。您选择一个单元格并选择冻结。它会冻结其上方的任何行以及留给它的列。freezePane