/**
* reads the given sheet
* @param $file
* @param $sheet
* @param $offset
*/
protected function readSheet($file, $sheet, $offset = 0)
{
$this->logInfo(sprintf('Try to read sheet "%s" from file "%s"', $sheet, $file));
$workbook = SpreadsheetParser::open($file);
$worksheets = $workbook->getWorksheets();
if (!array_key_exists($sheet, $worksheets)) {
$this->logWarning(sprintf('Tried to read non existing sheet with index "%s" from file "%s"', $sheet, $file));
return;
}
$properties = [];
$rowIterator = $workbook->createRowIterator($sheet);
foreach ($rowIterator as $rowIndex => $values) {
if ($this->headerDetector->isHeader($rowIndex, $values)) {
$properties = $this->describeProperties($values);
continue;
}
if ($rowIndex < $offset) {
continue;
}
if (!count($properties)) {
continue;
}
$this->processValues($properties, $values);
}
if (empty($properties)) {
$this->logWarning('No properties found to process');
}
}