From 96bd16a2905e1e8640a5b1702e50bb6ee7a25c7e Mon Sep 17 00:00:00 2001 From: Kane Wang Date: Tue, 8 Dec 2020 22:46:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E4=BA=86=E4=B8=AA=E5=A4=B4=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataManipulation/Excel/LoadFromExcel.cpp | 128 +++--------------- .../source/db/ocilib/db_oper.h | 10 +- 2 files changed, 23 insertions(+), 115 deletions(-) diff --git a/code/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.cpp b/code/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.cpp index 8e7921f..c036a74 100644 --- a/code/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.cpp +++ b/code/cpp/car_dealer_util/source/Data/DataManipulation/Excel/LoadFromExcel.cpp @@ -542,15 +542,15 @@ void LoadNewRepairMonitorReportFromXlsx( const std::wstring & NewRepairMonitorReportRecord record; - record.分公司名称_ = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - record.部门组名称_ = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - record.报案号_ = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); + record.分公司名称_ = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); + record.部门组名称_ = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); + record.报案号_ = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - if (record.报案号_.empty() == true) + if ( record.报案号_.empty() == true ) { //空行跳过 rowIndex++; - + continue; } @@ -717,115 +717,27 @@ void LoadNewRepairMonitorReportFromXlsx( const std::wstring & pBook->release(); } -void LoadRepairOrderFromXls( const std::wstring & filePath, - unsigned sheetIndex, - unsigned startRowIndex, - std::vector & orderVector ) -{ - Book * pBook = xlCreateBookW(); - Sheet * pSheet = nullptr; +/************************************************ +* \brief +* \param pBook +* \param sheetIndex +* \param captionRowIndex +* \param pszCaptionFormat +* \return +************************************************/ +bool checkExcelFileFormat( Book * pBook, int sheetIndex, int captionRowIndex, wchar_t * pszCaptionFormat[], int captionCount ) +{ if ( pBook == nullptr ) { - throw runtime_error( "libxl库加载失败!" ); + throw logic_error( "Excel文件指针为空!" ); } - setKey( pBook ); + Sheet * pSheet = pBook->getSheet( sheetIndex ); + int captionIndex = 0; - if ( pBook->load( filePath.c_str() ) != true ) + while ( captionIndex < captionCount ) { - string errorMessage = "打开文件失败!"; - errorMessage.append( pBook->errorMessage() ); - - throw runtime_error( errorMessage ); + } - - pSheet = pBook->getSheet( sheetIndex ); - - if ( pSheet == nullptr ) - { - string errorMessage = "读取sheet失败!"; - errorMessage.append( pBook->errorMessage() ); - - pBook->release(); - - throw runtime_error( errorMessage ); - } - - int lastRowIndex = pSheet->lastRow(); - int firstRowIndex = pSheet->firstRow(); - int rowIndex = firstRowIndex + startRowIndex; - - while ( rowIndex <= lastRowIndex ) - { - int colunmIndex = pSheet->firstCol(); - - // const wstring && branchName = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && orderNo = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && orderType = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && notifyNo = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && damageArea = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && damageDate = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && generatingDate = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && policyNo = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && policyNoJQX = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && plateNumber = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && brandName = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && isInsuranceObject = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && isSuccess = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && recommandDealerCode = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && recommandDealerName = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && recommandDealerCodeInNotify = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && recommandDealerNameInNotify = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && recommandDealerNameInSurvey = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && agentName = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && surveyor = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && checkDate = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && repairingStartDate = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && repairingFinishDate = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && status = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && lostItemID = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // const wstring && surveyorRecommandStatus = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true ); - // - // //空行跳过 - // if ( orderNo.empty() == true ) - // { - // rowIndex++; - // - // continue; - // } - // - // RepairOrder order( branchName, - // orderNo, - // orderType, - // notifyNo, - // damageArea, - // damageDate, - // generatingDate, - // policyNo, - // policyNoJQX, - // plateNumber, - // brandName, - // isInsuranceObject, - // isSuccess, - // recommandDealerCode, - // recommandDealerName, - // recommandDealerCodeInNotify, - // recommandDealerNameInNotify, - // recommandDealerNameInSurvey, - // agentName, - // surveyor, - // checkDate, - // repairingStartDate, - // repairingFinishDate, - // status, - // lostItemID, - // surveyorRecommandStatus ); - // - // orderVector.push_back( order ); - - rowIndex++; - } - - pBook->release(); } diff --git a/code/cpp/car_dealer_util/source/db/ocilib/db_oper.h b/code/cpp/car_dealer_util/source/db/ocilib/db_oper.h index 1aa86b3..1e75f11 100644 --- a/code/cpp/car_dealer_util/source/db/ocilib/db_oper.h +++ b/code/cpp/car_dealer_util/source/db/ocilib/db_oper.h @@ -1,6 +1,5 @@ - -#ifndef _DB_OPER_H -#define _DB_OPER_H + +#pragma once #include #include @@ -15,7 +14,4 @@ void l_error_handler(OCI_Error* pError); void output_error_message(const std::string& errorMessage); -std::string get_last_error_message(); - - -#endif \ No newline at end of file +std::string get_last_error_message(); \ No newline at end of file