diff --git a/src/core/excelreader.cpp b/src/core/excelreader.cpp index 0cbf9b3..4453988 100644 --- a/src/core/excelreader.cpp +++ b/src/core/excelreader.cpp @@ -1,16 +1,22 @@ #include "excelreader.h" #include +#include void ExcelReader::readSellersFromFile(const std::filesystem::path& filePath, Marketplace* market) { + xlnt::workbook wb; + std::ifstream mystream(filePath, std::ios::binary); + if(!mystream.is_open()) { + throw std::runtime_error("Could not open ecxel file"); + } + wb.load(mystream); + for (auto& seller : market->getSellers()) { seller->setState(Seller::State::DELETE); } - market->storeToDb(true); - xlnt::workbook wb; - wb.load(filePath); + market->storeToDb(true); auto ws = wb.sheet_by_index(0); const int START_ROW = 5; diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 689beb2..abde041 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -378,7 +378,7 @@ void MainWindow::onImportSellerExcelActionTriggered() if (filename.isEmpty()) return; - std::filesystem::path filePath(filename.toStdU16String()); + std::filesystem::path filePath(filename.toStdWString()); ExcelReader::readSellersFromFile(filePath, marketplace_.get()); }