public function SpreadsheetIterator::getOrigin in Migrate Spreadsheet 2.0.x
Same name and namespace in other branches
- 8 src/SpreadsheetIterator.php \Drupal\migrate_spreadsheet\SpreadsheetIterator::getOrigin()
Retrieves the top-left origin of data area.
Return value
string The top-left cell of data area (such as A2 or B5).
Overrides SpreadsheetIteratorInterface::getOrigin
File
- src/
SpreadsheetIterator.php, line 158
Class
- SpreadsheetIterator
- Provides a spreadsheet iterator.
Namespace
Drupal\migrate_spreadsheetCode
public function getOrigin() : string {
if (!isset($this->cache['origin'])) {
$config = $this
->getConfiguration();
if (empty($config['origin'])) {
// Defaulting to a table where the first row contains the header and
// data starts on the second row, column A.
return 'A2';
}
if ($coordinates = Coordinate::coordinateFromString($config['origin'])) {
$row_count = $this
->getRowsCount();
$column_count = $this
->getColumnsCount();
if ($coordinates[1] > $row_count || Coordinate::columnIndexFromString($coordinates[0]) > $column_count) {
$max = Coordinate::stringFromColumnIndex($column_count) . $row_count;
throw new \InvalidArgumentException("Origin '{$config['origin']}' is out of bounds. Max value is '{$max}'.");
}
}
$this->cache['origin'] = strtoupper($config['origin']);
}
return $this->cache['origin'];
}