From 2d1b9535cb6b03b28f81682ef9b6a27b5ea36797 Mon Sep 17 00:00:00 2001 From: Kane Wang Date: Wed, 18 Dec 2019 18:04:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=A7=8B=E7=BC=96=E5=86=99excel?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../car_dealer_util/car_dealer_util.vcxproj | 6 + .../car_dealer_util.vcxproj.filters | 21 +++ .../DataManipulation/Excel/ExportToExcel.cpp | 10 + .../DataManipulation/Excel/ExportToExcel.h | 2 + .../DataManipulation/Excel/LoadFromExcel.cpp | 36 ++++ .../DataManipulation/Excel/LoadFromExcel.h | 9 + .../CarDealerScheme/CarDealerScheme.h | 178 +++++++++++++++++- 7 files changed, 260 insertions(+), 2 deletions(-) create mode 100644 代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/ExportToExcel.cpp create mode 100644 代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/ExportToExcel.h create mode 100644 代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.cpp create mode 100644 代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.h diff --git a/代码/cpp/car_dealer_util/proj/vs2019/car_dealer_util/car_dealer_util.vcxproj b/代码/cpp/car_dealer_util/proj/vs2019/car_dealer_util/car_dealer_util.vcxproj index e6f1afc..824c979 100644 --- a/代码/cpp/car_dealer_util/proj/vs2019/car_dealer_util/car_dealer_util.vcxproj +++ b/代码/cpp/car_dealer_util/proj/vs2019/car_dealer_util/car_dealer_util.vcxproj @@ -17,6 +17,8 @@ + + @@ -32,6 +34,8 @@ + + @@ -68,9 +72,11 @@ + + diff --git a/代码/cpp/car_dealer_util/proj/vs2019/car_dealer_util/car_dealer_util.vcxproj.filters b/代码/cpp/car_dealer_util/proj/vs2019/car_dealer_util/car_dealer_util.vcxproj.filters index a00d184..a94ec87 100644 --- a/代码/cpp/car_dealer_util/proj/vs2019/car_dealer_util/car_dealer_util.vcxproj.filters +++ b/代码/cpp/car_dealer_util/proj/vs2019/car_dealer_util/car_dealer_util.vcxproj.filters @@ -41,6 +41,15 @@ {2c961c49-9981-447f-901d-c449e261fada} + + {3a2c4541-3486-4b47-9f4d-5aa7355190ed} + + + {1aa1a23b-6239-4b36-98be-cd6497547504} + + + {849ef05c-ca3c-479b-ad38-3b9eae188820} + @@ -55,6 +64,12 @@ 数据\数据结构\车商业绩表 + + 数据\数据管理\excel + + + 数据\数据管理\excel + @@ -88,5 +103,11 @@ 数据\数据结构\车商业绩表 + + 数据\数据管理\excel + + + 数据\数据管理\excel + \ No newline at end of file diff --git a/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/ExportToExcel.cpp b/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/ExportToExcel.cpp new file mode 100644 index 0000000..3fca7d9 --- /dev/null +++ b/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/ExportToExcel.cpp @@ -0,0 +1,10 @@ + +#include +#include "ExportToExcel.h" + +using namespace libxl; +using namespace std; + + + + diff --git a/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/ExportToExcel.h b/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/ExportToExcel.h new file mode 100644 index 0000000..079a383 --- /dev/null +++ b/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/ExportToExcel.h @@ -0,0 +1,2 @@ +#pragma once + diff --git a/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.cpp b/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.cpp new file mode 100644 index 0000000..5cd1dfa --- /dev/null +++ b/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.cpp @@ -0,0 +1,36 @@ +#include +#include +#include "LoadFromExcel.h" +#include + +using namespace std; +using namespace libxl; + +void SetKey( Book * pBook ) +{ + if ( pBook == nullptr ) + { + return; + } + + pBook->setKey(L"cpic", L"windows-202d21040bc4e70060bc6264a6ucu7i1"); +} + +/************************************************ +* \brief 从Excel文件读取车商方案表 +* \param filePath Excel文件路径 +* \param schemeMap 存放车商方案数据的map +************************************************/ +void LoadCarDealerSchemeFromXlsx( const wstring & filePath, + map & schemeMap ) +{ + Book* pBook = xlCreateXMLBookW(); + Sheet* pSheet = nullptr; + + if ( pBook == nullptr ) + { + throw runtime_error("libxl库加载失败!"); + } + + SetKey(pBook); +} diff --git a/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.h b/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.h new file mode 100644 index 0000000..74a85ba --- /dev/null +++ b/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.h @@ -0,0 +1,9 @@ + +#pragma once + +#include +#include +#include "../../Datastructure/CarDealerScheme/CarDealerScheme.h" +#include "../../Datastructure/CarDealerAchievement/CarDealerAchievement.h" + + diff --git a/代码/cpp/car_dealer_util/source/Data/Datastructure/CarDealerScheme/CarDealerScheme.h b/代码/cpp/car_dealer_util/source/Data/Datastructure/CarDealerScheme/CarDealerScheme.h index c91d2d2..0103d66 100644 --- a/代码/cpp/car_dealer_util/source/Data/Datastructure/CarDealerScheme/CarDealerScheme.h +++ b/代码/cpp/car_dealer_util/source/Data/Datastructure/CarDealerScheme/CarDealerScheme.h @@ -5,7 +5,182 @@ class CarDealerScheme { public: - + + + CarDealerScheme( const std::wstring & theYear, + const std::wstring & theMonth, + const std::wstring & carDealerCode, + const std::wstring & manHourPrice, + const std::wstring & partPrice, + const std::wstring & claimSupport, + const std::wstring & scheme, + const std::wstring & isQualified ) + : theYear( theYear ), + theMonth( theMonth ), + carDealerCode( carDealerCode ), + manHourPrice( manHourPrice ), + partPrice( partPrice ), + claimSupport( claimSupport ), + scheme( scheme ), + isQualified( isQualified ) + { + } + + CarDealerScheme( const wchar_t * theYear, + const wchar_t * theMonth, + const wchar_t * carDealerCode, + const wchar_t * manHourPrice, + const wchar_t * partPrice, + const wchar_t * claimSupport, + const wchar_t * scheme, + const wchar_t * isQualified ) + : theYear( theYear ), + theMonth( theMonth ), + carDealerCode( carDealerCode ), + manHourPrice( manHourPrice ), + partPrice( partPrice ), + claimSupport( claimSupport ), + scheme( scheme ), + isQualified( isQualified ) + { + } + + + CarDealerScheme( const CarDealerScheme & other ) + : theYear( other.theYear ), + theMonth( other.theMonth ), + carDealerCode( other.carDealerCode ), + manHourPrice( other.manHourPrice ), + partPrice( other.partPrice ), + claimSupport( other.claimSupport ), + scheme( other.scheme ), + isQualified( other.isQualified ) + { + } + + CarDealerScheme( CarDealerScheme && other ) + : theYear( std::move(other.theYear) ), + theMonth( std::move(other.theMonth) ), + carDealerCode( std::move(other.carDealerCode) ), + manHourPrice( std::move(other.manHourPrice) ), + partPrice( std::move(other.partPrice) ), + claimSupport( std::move(other.claimSupport) ), + scheme( std::move(other.scheme) ), + isQualified( std::move(other.isQualified) ) + { + } + + CarDealerScheme & operator=( const CarDealerScheme & other ) + { + if ( this == &other ) + return *this; + theYear = other.theYear; + theMonth = other.theMonth; + carDealerCode = other.carDealerCode; + manHourPrice = other.manHourPrice; + partPrice = other.partPrice; + claimSupport = other.claimSupport; + scheme = other.scheme; + isQualified = other.isQualified; + return *this; + } + + CarDealerScheme & operator=( CarDealerScheme && other ) + { + if ( this == &other ) + return *this; + theYear = std::move( other.theYear ); + theMonth = std::move( other.theMonth ); + carDealerCode = std::move( other.carDealerCode ); + manHourPrice = std::move( other.manHourPrice ); + partPrice = std::move( other.partPrice ); + claimSupport = std::move( other.claimSupport ); + scheme = std::move( other.scheme ); + isQualified = std::move( other.isQualified ); + return *this; + } + + + std::wstring getTheYear() const + { + return theYear; + } + + void setTheYear( const std::wstring & theYear ) + { + this->theYear = theYear; + } + + std::wstring getTheMonth() const + { + return theMonth; + } + + void setTheMonth( const std::wstring & theMonth ) + { + this->theMonth = theMonth; + } + + std::wstring getCarDealerCode() const + { + return carDealerCode; + } + + void setCarDealerCode( const std::wstring & carDealerCode ) + { + this->carDealerCode = carDealerCode; + } + + std::wstring getManHourPrice() const + { + return manHourPrice; + } + + void setManHourPrice( const std::wstring & manHourPrice ) + { + this->manHourPrice = manHourPrice; + } + + std::wstring getPartPrice() const + { + return partPrice; + } + + void setPartPrice( const std::wstring & partPrice ) + { + this->partPrice = partPrice; + } + + std::wstring getClaimSupport() const + { + return claimSupport; + } + + void setClaimSupport( const std::wstring & claimSupport ) + { + this->claimSupport = claimSupport; + } + + std::wstring getScheme() const + { + return scheme; + } + + void setScheme( const std::wstring & scheme ) + { + this->scheme = scheme; + } + + std::wstring getIsQualified() const + { + return isQualified; + } + + void setIsQualified( const std::wstring & isQualified ) + { + this->isQualified = isQualified; + } + private: std::wstring theYear; std::wstring theMonth; @@ -16,4 +191,3 @@ private: std::wstring scheme; std::wstring isQualified; //是否达成预期 }; -