Fix Excel import
This commit is contained in:
parent
77791e142c
commit
2d06de9907
1 changed files with 4 additions and 11 deletions
|
@ -22,20 +22,14 @@ std::size_t ExcelReader::readSellersFromFile(const fs::path& filePath, Marketpla
|
||||||
market->storeToDb(true);
|
market->storeToDb(true);
|
||||||
auto ws = wb.sheet_by_index(0);
|
auto ws = wb.sheet_by_index(0);
|
||||||
|
|
||||||
const int START_ROW = 5;
|
for (auto row : ws.rows(true)) {
|
||||||
const int END_ROW = 504;
|
// Skip the row if the first value is not a number (= seller no)
|
||||||
|
if (row[0].data_type() != xlnt::cell::type::number) {
|
||||||
int rowCount{};
|
|
||||||
for (const auto& row : ws.rows(false)) {
|
|
||||||
if (rowCount < START_ROW) {
|
|
||||||
++rowCount;
|
|
||||||
continue;
|
continue;
|
||||||
} else if (rowCount > END_ROW) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Skip the row if the seller has neither a first name nor a surname
|
||||||
if (row[2].value<std::string>().empty() && row[3].value<std::string>().empty()) {
|
if (row[2].value<std::string>().empty() && row[3].value<std::string>().empty()) {
|
||||||
++rowCount;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto seller = std::make_unique<Seller>();
|
auto seller = std::make_unique<Seller>();
|
||||||
|
@ -46,7 +40,6 @@ std::size_t ExcelReader::readSellersFromFile(const fs::path& filePath, Marketpla
|
||||||
std::string lastName = row[3].value<std::string>();
|
std::string lastName = row[3].value<std::string>();
|
||||||
seller->setLastName(trim(lastName));
|
seller->setLastName(trim(lastName));
|
||||||
market->getSellers().push_back(std::move(seller));
|
market->getSellers().push_back(std::move(seller));
|
||||||
rowCount++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there was no special seller "Sonderkonto" in import data, then create one
|
// If there was no special seller "Sonderkonto" in import data, then create one
|
||||||
|
|
Loading…
Reference in a new issue