Skip to content

Commit fd4e256

Browse files
committed
Rationalise the worksheet getHighestRowAndColumn() and getHighestDataRowAndColumn() methods, and return the cell address as a string rather than an array
1 parent 42dde14 commit fd4e256

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/PhpSpreadsheet/Worksheet/Worksheet.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ public function setProtection(Protection $protection)
10671067
*
10681068
* @return string Highest column name
10691069
*/
1070-
public function getHighestColumn($row = null)
1070+
public function getHighestColumn($row = null): string
10711071
{
10721072
if ($row === null) {
10731073
return Coordinate::stringFromColumnIndex($this->cachedHighestColumn);
@@ -1084,7 +1084,7 @@ public function getHighestColumn($row = null)
10841084
*
10851085
* @return string Highest column name that contains data
10861086
*/
1087-
public function getHighestDataColumn($row = null)
1087+
public function getHighestDataColumn($row = null): string
10881088
{
10891089
return $this->cellCollection->getHighestColumn($row);
10901090
}
@@ -1097,7 +1097,7 @@ public function getHighestDataColumn($row = null)
10971097
*
10981098
* @return int Highest row number
10991099
*/
1100-
public function getHighestRow($column = null)
1100+
public function getHighestRow(?string $column = null): int
11011101
{
11021102
if ($column === null) {
11031103
return $this->cachedHighestRow;
@@ -1114,19 +1114,31 @@ public function getHighestRow($column = null)
11141114
*
11151115
* @return int Highest row number that contains data
11161116
*/
1117-
public function getHighestDataRow($column = null)
1117+
public function getHighestDataRow(?string $column = null): int
11181118
{
11191119
return $this->cellCollection->getHighestRow($column);
11201120
}
11211121

1122+
/**
1123+
* Get highest worksheet column and highest row.
1124+
*
1125+
* @return string Highest column name and highest row number
1126+
*/
1127+
public function getHighestRowAndColumn(): string
1128+
{
1129+
return $this->getHighestColumn() . $this->getHighestRow();
1130+
}
1131+
11221132
/**
11231133
* Get highest worksheet column and highest row that have cell records.
11241134
*
1125-
* @return array Highest column name and highest row number
1135+
* @return string Highest column name and highest row number
11261136
*/
1127-
public function getHighestRowAndColumn()
1137+
public function getHighestDataRowAndColumn(): string
11281138
{
1129-
return $this->cellCollection->getHighestRowAndColumn();
1139+
$highestRowAndColumn = $this->cellCollection->getHighestRowAndColumn();
1140+
1141+
return $highestRowAndColumn['column'] . $highestRowAndColumn['row'];
11301142
}
11311143

11321144
/**

0 commit comments

Comments
 (0)