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 977209b..5d6a8c6 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 @@ -20,6 +20,7 @@ + @@ -48,6 +49,7 @@ + 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 b77c246..f6cc45c 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 @@ -83,6 +83,9 @@ {7f951e1f-a198-4833-bbec-853de77c8cfe} + + {ef490558-0c27-4a12-a626-583699d6a35f} + @@ -133,6 +136,9 @@ 数据\全局对象 + + 数据\数据管理\导入导出\直接导入导出 + @@ -205,5 +211,8 @@ 数据\全局对象 + + 数据\数据管理\导入导出\直接导入导出 + \ No newline at end of file diff --git a/代码/cpp/car_dealer_util/source/Data/DataManipulation/FromExcelToOracle/FromExcelToOracle.cpp b/代码/cpp/car_dealer_util/source/Data/DataManipulation/FromExcelToOracle/FromExcelToOracle.cpp new file mode 100644 index 0000000..f2d326d --- /dev/null +++ b/代码/cpp/car_dealer_util/source/Data/DataManipulation/FromExcelToOracle/FromExcelToOracle.cpp @@ -0,0 +1,80 @@ +#include +#include +#include +#include +#include +#include "FromExcelToOracle.h" + +#include "../../excel/excel.h" + +using namespace std;; +using namespace ocilib; +using namespace libxl; + +void RepairMonitoringFromExcelToOracle( const std::wstring & filePath, + unsigned int sheetIndex, + unsigned int titleRowIndex, + unsigned int firstRowIndex, + const std::string & tnsName, + const std::string & userName, + const std::string & password ) +{ + //防御性验证 + if ( filePath.empty() == true || + tnsName.empty() == true || + userName.empty() == true || + password.empty() == true ) + { + throw runtime_error( "参数错误!" ); + } + + //libxl对象 + Book * pBook = xlCreateBookW(); + Sheet * pSheet = nullptr; + map titleMap; //存放标题行 + unsigned int firstColumnIndex; //第一列 + unsigned int lastColumnIndex; //最后一列 + unsigned int firstRowIndex; + unsigned int lastRowIndex; + + //ocilib对象 + Connection * pConnection = nullptr; + Statement * pStatement = nullptr; + + if ( pBook == nullptr ) + { + throw runtime_error( "libxl初始化失败!" ); + } + + if ( pBook->load( filePath.c_str() ) != true ) + { + throw runtime_error( "打开excel文件失败!" ); + } + + pSheet = pBook->getSheet( sheetIndex ); + + if ( pSheet == nullptr ) + { + throw runtime_error( "读取sheet失败失败!" ); + } + + firstColumnIndex = pSheet->firstCol(); + lastColumnIndex = pSheet->lastCol(); + firstRowIndex = pSheet->firstRow(); + lastRowIndex = pSheet->lastRow(); + + unsigned int index = firstColumnIndex; + + //保存标题 + while ( index <= lastColumnIndex ) + { + wstring && title = ReadCellStringFromXlsx( pBook, sheetIndex, titleRowIndex, index, false ); + + titleMap.insert( pair( index, title ) ); + + ++index; + } + + //逐行保存数据 + +} diff --git a/代码/cpp/car_dealer_util/source/Data/DataManipulation/FromExcelToOracle/FromExcelToOracle.h b/代码/cpp/car_dealer_util/source/Data/DataManipulation/FromExcelToOracle/FromExcelToOracle.h new file mode 100644 index 0000000..487ebdb --- /dev/null +++ b/代码/cpp/car_dealer_util/source/Data/DataManipulation/FromExcelToOracle/FromExcelToOracle.h @@ -0,0 +1,11 @@ +#pragma once + +#include + +void RepairMonitoringFromExcelToOracle( const std::wstring & filePath, + unsigned int sheetIndex, + unsigned int titleRowIndex, + unsigned int firstRowIndex, + const std::string & tnsName, + const std::string & userName, + const std::string & password ); diff --git a/数据/新送返修监控报表 - 字段.xlsx b/数据/新送返修监控报表 - 字段.xlsx new file mode 100644 index 0000000..c6b46d7 Binary files /dev/null and b/数据/新送返修监控报表 - 字段.xlsx differ diff --git a/数据/新送返修监控报表.xlsx b/数据/新送返修监控报表.xlsx new file mode 100644 index 0000000..057b991 Binary files /dev/null and b/数据/新送返修监控报表.xlsx differ