open excel files with umlauts on win works now

This commit is contained in:
Martin Brodbeck 2018-08-09 12:52:15 +02:00
parent 27edf6b6ea
commit a04e8ad837
2 changed files with 10 additions and 4 deletions

View file

@ -1,16 +1,22 @@
#include "excelreader.h" #include "excelreader.h"
#include <xlnt/xlnt.hpp> #include <xlnt/xlnt.hpp>
#include <fstream>
void ExcelReader::readSellersFromFile(const std::filesystem::path& filePath, Marketplace* market) 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()) { for (auto& seller : market->getSellers()) {
seller->setState(Seller::State::DELETE); seller->setState(Seller::State::DELETE);
} }
market->storeToDb(true);
xlnt::workbook wb; market->storeToDb(true);
wb.load(filePath);
auto ws = wb.sheet_by_index(0); auto ws = wb.sheet_by_index(0);
const int START_ROW = 5; const int START_ROW = 5;

View file

@ -378,7 +378,7 @@ void MainWindow::onImportSellerExcelActionTriggered()
if (filename.isEmpty()) if (filename.isEmpty())
return; return;
std::filesystem::path filePath(filename.toStdU16String()); std::filesystem::path filePath(filename.toStdWString());
ExcelReader::readSellersFromFile(filePath, marketplace_.get()); ExcelReader::readSellersFromFile(filePath, marketplace_.get());
} }