做了一点点重构
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
				
			|||||||
#include <libxl.h>
 | 
					#include <libxl.h>
 | 
				
			||||||
#include <stdexcept>
 | 
					#include <stdexcept>
 | 
				
			||||||
#include "LoadFromExcel.h"
 | 
					#include "LoadFromExcel.h"
 | 
				
			||||||
#include "../../excel/excel.h"
 | 
					#include "../../excel/excel.h"
 | 
				
			||||||
@@ -1072,7 +1072,7 @@ void LoadNewRepairMonitorReportFromXlsx( const std::wstring &
 | 
				
			|||||||
* \param pszCaptionFormat 
 | 
					* \param pszCaptionFormat 
 | 
				
			||||||
* \return 
 | 
					* \return 
 | 
				
			||||||
************************************************/
 | 
					************************************************/
 | 
				
			||||||
bool checkExcelFileFormat( Book * pBook, int sheetIndex, int captionRowIndex, const wchar_t * pszCaptionFormat[], int captionCount )
 | 
					/*bool checkExcelFileFormat( Book * pBook, int sheetIndex, int captionRowIndex, const wchar_t * pszCaptionFormat[], int captionCount )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if ( pBook == nullptr )
 | 
						if ( pBook == nullptr )
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@@ -1103,4 +1103,4 @@ bool checkExcelFileFormat( Book * pBook, int sheetIndex, int captionRowIndex, co
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return isEqual;
 | 
						return isEqual;
 | 
				
			||||||
}
 | 
					}*/
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -163,3 +163,41 @@ libxl::Sheet * getXlsxSheetByName( libxl::IBookT<wchar_t> * pBook, const std::ws
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	return pSheet;
 | 
						return pSheet;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool checkExcelFileFormat(Book* pBook,
 | 
				
			||||||
 | 
						int             sheetIndex,
 | 
				
			||||||
 | 
						int             captionRowIndex,
 | 
				
			||||||
 | 
						const wchar_t* pszCaptionFormat[],
 | 
				
			||||||
 | 
						int             captionCount)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (pBook == nullptr)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							throw logic_error("Excel文件指针为空!");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (sheetIndex < 0 || captionRowIndex < 0)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							throw logic_error("标题行参数错误!");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Sheet* pSheet = pBook->getSheet(sheetIndex);
 | 
				
			||||||
 | 
						int     captionIndex = 0;
 | 
				
			||||||
 | 
						bool    isEqual = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						while (captionIndex < captionCount)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							const wchar_t* pwszCaption = pSheet->readStr(captionRowIndex, captionIndex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (wcscmp(pwszCaption, pszCaptionFormat[captionIndex]) != 0)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								isEqual = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							captionIndex++;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return isEqual;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,6 +1,4 @@
 | 
				
			|||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
#ifndef EXCEL_H_
 | 
					 | 
				
			||||||
#define EXCEL_H_
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <libxl.h>
 | 
					#include <libxl.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -33,5 +31,18 @@ std::wstring ReadCellStringFromXlsx( libxl::IBookT<wchar_t> * pBook,
 | 
				
			|||||||
************************************************/
 | 
					************************************************/
 | 
				
			||||||
libxl::Sheet * getXlsxSheetByName( libxl::IBookT<wchar_t> * pBook, const std::wstring & sheetName );
 | 
					libxl::Sheet * getXlsxSheetByName( libxl::IBookT<wchar_t> * pBook, const std::wstring & sheetName );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/************************************************
 | 
				
			||||||
 | 
					* \brief 核对excel表格的内容,根据pszCaptionFormat参数提供的表头数组来核对
 | 
				
			||||||
 | 
					* \param pBook excel文件指针
 | 
				
			||||||
 | 
					* \param sheetIndex 要核对的sheet索引
 | 
				
			||||||
 | 
					* \param captionRowIndex 标题行索引
 | 
				
			||||||
 | 
					* \param pszCaptionFormat 包含标题内容的字符串数组
 | 
				
			||||||
 | 
					* \param captionCount 标题数量
 | 
				
			||||||
 | 
					* \return
 | 
				
			||||||
 | 
					************************************************/
 | 
				
			||||||
 | 
					bool checkExcelFileFormat( libxl::Book *   pBook,
 | 
				
			||||||
 | 
					                           int             sheetIndex,
 | 
				
			||||||
 | 
					                           int             captionRowIndex,
 | 
				
			||||||
 | 
					                           const wchar_t * pszCaptionFormat[],
 | 
				
			||||||
 | 
					                           int             captionCount );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user