added importing from csv

This commit is contained in:
Martin Brodbeck 2019-09-26 16:41:39 +02:00
parent 780e37f565
commit 8265212c11
8 changed files with 112 additions and 6 deletions

View file

@ -12,6 +12,7 @@
#include <utils.h>
#include <excelreader.h>
#include <csvreader.h>
#include <posprinter.h>
#include <exception>
@ -445,14 +446,20 @@ void MainWindow::onImportSellerExcelActionTriggered()
.exec();
auto filename = QFileDialog::getOpenFileName(this, "Verkäufer importieren", QString(),
"Excel Dateien (*.xlsx *.xls)");
"Excel Dateien (*.xlsx);CSV Dateien (*.csv)");
if (filename.isEmpty())
return;
fs::path filePath(filename.toStdWString());
std::size_t numImported = ExcelReader::readSellersFromFile(filePath, marketplace_.get());
std::size_t numImported{};
if (case_insensitive_match(filePath.extension().string(), std::string("xslx"))) {
numImported = ExcelReader::readSellersFromFile(filePath, marketplace_.get());
} else {
numImported = CsvReader::readSellersFromFile(filePath, marketplace_.get());
}
updateStatLabel();
using namespace std::string_literals;