@@ -201,9 +201,16 @@ class Worksheet implements IComparable
201
201
/**
202
202
* Freeze pane.
203
203
*
204
- * @var string
204
+ * @var null|string
205
+ */
206
+ private $ freezePane ;
207
+
208
+ /**
209
+ * Default position of the right bottom pane.
210
+ *
211
+ * @var null|string
205
212
*/
206
- private $ freezePane = '' ;
213
+ private $ topLeftCell ;
207
214
208
215
/**
209
216
* Show gridlines?
@@ -1975,27 +1982,33 @@ public function getFreezePane()
1975
1982
/**
1976
1983
* Freeze Pane.
1977
1984
*
1978
- * @param string $pCell Cell (i.e. A2)
1979
- * Examples:
1980
- * A2 will freeze the rows above cell A2 (i.e row 1)
1981
- * B1 will freeze the columns to the left of cell B1 (i.e column A)
1982
- * B2 will freeze the rows above and to the left of cell A2
1983
- * (i.e row 1 and column A)
1985
+ * Examples:
1986
+ *
1987
+ * - A2 will freeze the rows above cell A2 (i.e row 1)
1988
+ * - B1 will freeze the columns to the left of cell B1 (i.e column A)
1989
+ * - B2 will freeze the rows above and to the left of cell A2 (i.e row 1 and column A)
1990
+ *
1991
+ * @param null|string $cell Position of the split
1992
+ * @param null|string $topLeftCell default position of the right bottom pane
1984
1993
*
1985
1994
* @throws Exception
1986
1995
*
1987
1996
* @return Worksheet
1988
1997
*/
1989
- public function freezePane ($ pCell )
1998
+ public function freezePane ($ cell , $ topLeftCell = null )
1990
1999
{
1991
- // Uppercase coordinate
1992
- $ pCell = strtoupper ($ pCell );
1993
- if (strpos ($ pCell , ': ' ) === false && strpos ($ pCell , ', ' ) === false ) {
1994
- $ this ->freezePane = $ pCell ;
1995
- } else {
2000
+ if (is_string ($ cell ) && (strpos ($ cell , ': ' ) !== false || strpos ($ cell , ', ' ) !== false )) {
1996
2001
throw new Exception ('Freeze pane can not be set on a range of cells. ' );
1997
2002
}
1998
2003
2004
+ if ($ cell !== null && $ topLeftCell === null ) {
2005
+ $ coordinate = Coordinate::coordinateFromString ($ cell );
2006
+ $ topLeftCell = $ coordinate [0 ] . ($ coordinate [1 ] + 1 );
2007
+ }
2008
+
2009
+ $ this ->freezePane = $ cell ;
2010
+ $ this ->topLeftCell = $ topLeftCell ;
2011
+
1999
2012
return $ this ;
2000
2013
}
2001
2014
@@ -2005,8 +2018,6 @@ public function freezePane($pCell)
2005
2018
* @param int $columnIndex Numeric column coordinate of the cell
2006
2019
* @param int $row Numeric row coordinate of the cell
2007
2020
*
2008
- * @throws Exception
2009
- *
2010
2021
* @return Worksheet
2011
2022
*/
2012
2023
public function freezePaneByColumnAndRow ($ columnIndex , $ row )
@@ -2021,7 +2032,17 @@ public function freezePaneByColumnAndRow($columnIndex, $row)
2021
2032
*/
2022
2033
public function unfreezePane ()
2023
2034
{
2024
- return $ this ->freezePane ('' );
2035
+ return $ this ->freezePane (null );
2036
+ }
2037
+
2038
+ /**
2039
+ * Get the default position of the right bottom pane.
2040
+ *
2041
+ * @return int
2042
+ */
2043
+ public function getTopLeftCell ()
2044
+ {
2045
+ return $ this ->topLeftCell ;
2025
2046
}
2026
2047
2027
2048
/**
@@ -2622,6 +2643,7 @@ public function toArray($nullValue = null, $calculateFormulas = true, $formatDat
2622
2643
// Identify the range that we need to extract from the worksheet
2623
2644
$ maxCol = $ this ->getHighestColumn ();
2624
2645
$ maxRow = $ this ->getHighestRow ();
2646
+
2625
2647
// Return
2626
2648
return $ this ->rangeToArray ('A1: ' . $ maxCol . $ maxRow , $ nullValue , $ calculateFormulas , $ formatData , $ returnCellRef );
2627
2649
}
0 commit comments