started with xls import
This commit is contained in:
parent
7d405234d4
commit
e295c6a743
7 changed files with 73 additions and 4 deletions
|
@ -2,6 +2,8 @@ set(Boost_USE_STATIC_LIBS ON)
|
|||
|
||||
find_package(Boost 1.62 COMPONENTS date_time REQUIRED)
|
||||
find_package(SQLite3 REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(XLNT REQUIRED xlnt)
|
||||
|
||||
set(CORE_SOURCES
|
||||
database.cpp
|
||||
|
@ -10,13 +12,12 @@ set(CORE_SOURCES
|
|||
article.cpp
|
||||
sale.cpp
|
||||
marketplace.cpp
|
||||
excelreader.cpp
|
||||
)
|
||||
|
||||
add_library(core STATIC ${CORE_SOURCES})
|
||||
target_link_libraries(core Boost::boost Boost::date_time)
|
||||
target_link_libraries(core Boost::boost Boost::date_time sqlite3 ${XLNT_LIBRARIES})
|
||||
if (WIN32)
|
||||
target_link_libraries(core sqlite3 bcrypt)
|
||||
else()
|
||||
target_link_libraries(core sqlite3)
|
||||
target_link_libraries(core bcrypt)
|
||||
endif()
|
||||
target_include_directories(core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
18
src/core/excelreader.cpp
Normal file
18
src/core/excelreader.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include "excelreader.h"
|
||||
|
||||
#include <xlnt/xlnt.hpp>
|
||||
|
||||
void ExcelReader::readSellersFromFile(const std::string& filename, Marketplace* market)
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
wb.load(filename);
|
||||
auto ws = wb.sheet_by_index(0);
|
||||
|
||||
const int START_ROW = 6;
|
||||
const int END_ROW = 349;
|
||||
|
||||
for (const auto& row : ws.rows(false)) {
|
||||
//auto test = row[0].value<int>();
|
||||
//std::cout << test << "\n";
|
||||
}
|
||||
}
|
18
src/core/excelreader.h
Normal file
18
src/core/excelreader.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef EXCEL_READER_H
|
||||
#define EXCEL_READER_H
|
||||
|
||||
#include "seller.h"
|
||||
#include "marketplace.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class ExcelReader
|
||||
{
|
||||
public:
|
||||
static void readSellersFromFile(const std::string& filename,
|
||||
Marketplace* market);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
class ExcelReader;
|
||||
|
||||
namespace
|
||||
{
|
||||
using SellersVec = std::vector<std::unique_ptr<Seller>>;
|
||||
|
@ -49,6 +51,8 @@ class Marketplace
|
|||
|
||||
void exportReportToCSV(const std::string& filename, int feeInPercent, int maxFeeInEuro);
|
||||
|
||||
friend class ExcelReader;
|
||||
|
||||
private:
|
||||
SellersVec sellers_;
|
||||
SalesVec sales_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue