You are here

public function MigrateSourceSpreadsheet::getNextRow in Migrate 7.2

Implements MigrateSource::getNextRow().

Return value

null|object

File

plugins/sources/spreadsheet.inc, line 230
Define a MigrateSource for importing from spreadsheet files.

Class

MigrateSourceSpreadsheet
Implements MigrateSource, to handle imports from XLS files.

Code

public function getNextRow() {
  migrate_instrument_start('MigrateSourceSpreadsheet::next');
  ++$this->rowNumber;
  if ($this->rowNumber <= $this->rows) {
    $row_values = array();
    for ($col = 0; $col < $this->cols; ++$col) {
      if (in_array($this->fields[$col], $this->columns) || empty($this->columns)) {
        $row_values[$this->fields[$col]] = trim($this->worksheet
          ->getCellByColumnAndRow($col, $this->rowNumber)
          ->getValue());
      }
    }
    return (object) $row_values;
  }
  else {

    // EOF, close the workbook.
    $this
      ->unload();
    migrate_instrument_stop('MigrateSourceSpreadsheet::next');
    return NULL;
  }
}