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 d3e6d3d..b19789d 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
@@ -21,7 +21,9 @@
+
+
@@ -38,6 +40,8 @@
+
+
{B12702AD-ABFB-343A-A199-8E24837244A3}
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 a94ec87..8b33381 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
@@ -50,6 +50,12 @@
{849ef05c-ca3c-479b-ad38-3b9eae188820}
+
+ {c6a0a5fd-26f9-4d8d-84a5-ce7edb04eb5f}
+
+
+ {61d5dd61-6b1f-4507-bb22-4ce463ad5b85}
+
@@ -70,6 +76,12 @@
数据\数据管理\excel
+
+ 测试
+
+
+ excel
+
@@ -109,5 +121,11 @@
数据\数据管理\excel
+
+ 测试
+
+
+ excel
+
\ No newline at end of file
diff --git a/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.cpp b/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.cpp
index f0754e6..3bea9bc 100644
--- a/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.cpp
+++ b/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.cpp
@@ -1,30 +1,21 @@
#include
-#include
-#include "LoadFromExcel.h"
#include
+#include "LoadFromExcel.h"
+#include "../../excel/excel.h"
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,
- unsigned int sheetIndex,
- unsigned int firstRowIndex,
- map & schemeMap )
+void LoadCarDealerSchemeFromXlsx( const wstring & filePath,
+ unsigned int sheetIndex,
+ unsigned int startRowIndex,
+ vector & schemeVector )
{
Book * pBook = xlCreateXMLBookW();
Sheet * pSheet = nullptr;
@@ -34,7 +25,7 @@ void LoadCarDealerSchemeFromXlsx( const wstring & filePath,
throw runtime_error( "libxl库加载失败!" );
}
- SetKey( pBook );
+ setKey( pBook );
if ( pBook->load( filePath.c_str() ) != true )
{
@@ -51,8 +42,43 @@ void LoadCarDealerSchemeFromXlsx( const wstring & filePath,
string errorMessage = "读取sheet失败!";
errorMessage.append( pBook->errorMessage() );
+ pBook->release();
+
throw runtime_error( errorMessage );
}
-
+ int lastRowIndex = pSheet->lastRow();
+ int firstRowIndex = pSheet->firstRow();
+ int firstColumnIndex = pSheet->firstCol();
+ int rowIndex = firstRowIndex + startRowIndex;
+
+ while ( rowIndex <= lastRowIndex )
+ {
+ int colunmIndex = firstRowIndex;
+
+ const wstring && theYear = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex, true );
+ const wstring && theMonth = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 1, true );
+ const wstring && carDealerCode = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 2, true );
+ const wstring && carDealerName = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 3, true );
+ const wstring && manHourPrice = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 4, true );
+ const wstring && partPrice = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 5, true );
+ const wstring && claimSupport = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 6, true );
+ const wstring && scheme = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 7, true );
+ const wstring && isQualified = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 8, true );
+
+ CarDealerScheme carDealerScheme( theYear,
+ theMonth,
+ carDealerCode,
+ manHourPrice,
+ partPrice,
+ claimSupport,
+ scheme,
+ isQualified );
+
+ schemeVector.push_back( carDealerScheme );
+
+ rowIndex++;
+ }
+
+ pBook->release();
}
diff --git a/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.h b/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.h
index 74a85ba..9d69edb 100644
--- a/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.h
+++ b/代码/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.h
@@ -1,9 +1,11 @@
-
-#pragma once
+#pragma once
-#include