mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-31 04:28:51 +00:00
getColumnIterator() getRowIterator() synonyms for getCellIterator() methods in Row and Column objects
This commit is contained in:
@@ -52,14 +52,23 @@ class Column
|
||||
*
|
||||
* @param int $startRow The row number at which to start iterating
|
||||
* @param int $endRow Optionally, the row number at which to stop iterating
|
||||
*
|
||||
* @return ColumnCellIterator
|
||||
*/
|
||||
public function getCellIterator($startRow = 1, $endRow = null)
|
||||
public function getCellIterator($startRow = 1, $endRow = null): ColumnCellIterator
|
||||
{
|
||||
return new ColumnCellIterator($this->worksheet, $this->columnIndex, $startRow, $endRow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get row iterator. Synonym for getCellIterator().
|
||||
*
|
||||
* @param int $startRow The row number at which to start iterating
|
||||
* @param int $endRow Optionally, the row number at which to stop iterating
|
||||
*/
|
||||
public function getRowIterator($startRow = 1, $endRow = null): ColumnCellIterator
|
||||
{
|
||||
return $this->getCellIterator($startRow, $endRow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a boolean true if the column contains no cells. By default, this means that no cell records exist in the
|
||||
* collection for this column. false will be returned otherwise.
|
||||
|
||||
@@ -51,14 +51,23 @@ class Row
|
||||
*
|
||||
* @param string $startColumn The column address at which to start iterating
|
||||
* @param string $endColumn Optionally, the column address at which to stop iterating
|
||||
*
|
||||
* @return RowCellIterator
|
||||
*/
|
||||
public function getCellIterator($startColumn = 'A', $endColumn = null)
|
||||
public function getCellIterator($startColumn = 'A', $endColumn = null): RowCellIterator
|
||||
{
|
||||
return new RowCellIterator($this->worksheet, $this->rowIndex, $startColumn, $endColumn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column iterator. Synonym for getCellIterator().
|
||||
*
|
||||
* @param string $startColumn The column address at which to start iterating
|
||||
* @param string $endColumn Optionally, the column address at which to stop iterating
|
||||
*/
|
||||
public function getColumnIterator($startColumn = 'A', $endColumn = null): RowCellIterator
|
||||
{
|
||||
return $this->getCellIterator($startColumn, $endColumn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a boolean true if the row contains no cells. By default, this means that no cell records exist in the
|
||||
* collection for this row. false will be returned otherwise.
|
||||
|
||||
@@ -40,4 +40,14 @@ class ColumnTest extends TestCase
|
||||
self::assertInstanceOf(ColumnCellIterator::class, $cellIterator);
|
||||
$spreadsheet->disconnectWorksheets();
|
||||
}
|
||||
|
||||
public function testGetRowIterator(): void
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$column = new Column($sheet);
|
||||
$cellIterator = $column->getRowIterator();
|
||||
self::assertInstanceOf(ColumnCellIterator::class, $cellIterator);
|
||||
$spreadsheet->disconnectWorksheets();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,4 +40,14 @@ class RowTest extends TestCase
|
||||
self::assertInstanceOf(RowCellIterator::class, $cellIterator);
|
||||
$spreadsheet->disconnectWorksheets();
|
||||
}
|
||||
|
||||
public function testGetColumnIterator(): void
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$row = new Row($sheet);
|
||||
$cellIterator = $row->getColumnIterator();
|
||||
self::assertInstanceOf(RowCellIterator::class, $cellIterator);
|
||||
$spreadsheet->disconnectWorksheets();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user