fix(Import): increase error again, when there was a gap in column headers

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon
2024-11-26 13:09:35 +01:00
parent 044d62d5c2
commit 50815ae67b

View File

@ -457,6 +457,8 @@ class ImportService extends SuperService {
$index = 0; $index = 0;
$countMatchingColumnsFromConfig = 0; $countMatchingColumnsFromConfig = 0;
$countCreatedColumnsFromConfig = 0; $countCreatedColumnsFromConfig = 0;
$lastCellWasEmpty = false;
$hasGapInTitles = false;
foreach ($cellIterator as $cell) { foreach ($cellIterator as $cell) {
if ($cell && $cell->getValue() !== null && $cell->getValue() !== '') { if ($cell && $cell->getValue() !== null && $cell->getValue() !== '') {
$title = $cell->getValue(); $title = $cell->getValue();
@ -480,12 +482,16 @@ class ImportService extends SuperService {
// Convert data type to our data type // Convert data type to our data type
$dataTypes[] = $this->parseColumnDataType($secondRowCellIterator->current()); $dataTypes[] = $this->parseColumnDataType($secondRowCellIterator->current());
if ($lastCellWasEmpty) {
$hasGapInTitles = true;
}
$lastCellWasEmpty = false;
} else { } else {
$this->logger->debug('No cell given or cellValue is empty while loading columns for importing'); $this->logger->debug('No cell given or cellValue is empty while loading columns for importing');
if ($cell->getDataType() === 'null') { if ($cell->getDataType() === 'null') {
// LibreOffice generated XLSX doc may have more empty columns in the first row. // LibreOffice generated XLSX doc may have more empty columns in the first row.
// Continue without increasing error count. // Continue without increasing error count, but leave a marker to detect gaps in titles.
// Question: What about tables where a column does not have a heading? $lastCellWasEmpty = true;
continue; continue;
} }
$this->countErrors++; $this->countErrors++;
@ -494,6 +500,11 @@ class ImportService extends SuperService {
$index++; $index++;
} }
if ($hasGapInTitles) {
$this->logger->info('Imported table is having a gap in column titles');
$this->countErrors++;
}
$this->rawColumnTitles = $titles; $this->rawColumnTitles = $titles;
$this->rawColumnDataTypes = $dataTypes; $this->rawColumnDataTypes = $dataTypes;