@@ -201,9 +201,16 @@ class Worksheet implements IComparable
201201 /**
202202 * Freeze pane.
203203 *
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
205212 */
206- private $ freezePane = '' ;
213+ private $ topLeftCell ;
207214
208215 /**
209216 * Show gridlines?
@@ -1975,27 +1982,33 @@ public function getFreezePane()
19751982 /**
19761983 * Freeze Pane.
19771984 *
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
19841993 *
19851994 * @throws Exception
19861995 *
19871996 * @return Worksheet
19881997 */
1989- public function freezePane ($ pCell )
1998+ public function freezePane ($ cell , $ topLeftCell = null )
19901999 {
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 )) {
19962001 throw new Exception ('Freeze pane can not be set on a range of cells. ' );
19972002 }
19982003
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+
19992012 return $ this ;
20002013 }
20012014
@@ -2005,8 +2018,6 @@ public function freezePane($pCell)
20052018 * @param int $columnIndex Numeric column coordinate of the cell
20062019 * @param int $row Numeric row coordinate of the cell
20072020 *
2008- * @throws Exception
2009- *
20102021 * @return Worksheet
20112022 */
20122023 public function freezePaneByColumnAndRow ($ columnIndex , $ row )
@@ -2021,7 +2032,17 @@ public function freezePaneByColumnAndRow($columnIndex, $row)
20212032 */
20222033 public function unfreezePane ()
20232034 {
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 ;
20252046 }
20262047
20272048 /**
@@ -2622,6 +2643,7 @@ public function toArray($nullValue = null, $calculateFormulas = true, $formatDat
26222643 // Identify the range that we need to extract from the worksheet
26232644 $ maxCol = $ this ->getHighestColumn ();
26242645 $ maxRow = $ this ->getHighestRow ();
2646+
26252647 // Return
26262648 return $ this ->rangeToArray ('A1: ' . $ maxCol . $ maxRow , $ nullValue , $ calculateFormulas , $ formatData , $ returnCellRef );
26272649 }
0 commit comments