diff --git a/.gitignore b/.gitignore index f3c3467..c1cd801 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ /xlnt /iKXiao/x64 /Test_iKXiao/x64 +/Test_iKXiao/tmp +/iKXiao/tmp diff --git a/Test_iKXiao/Test_iKXiao.cpp b/Test_iKXiao/Test_iKXiao.cpp index a92ec0f..84dcf8c 100644 --- a/Test_iKXiao/Test_iKXiao.cpp +++ b/Test_iKXiao/Test_iKXiao.cpp @@ -4,36 +4,140 @@ #include #include "..\iKXiao\iKXiao.h" -int main() +void normalTest() { - IK_WORKBOOK wb = iKXiao::Ins().OpenExcel("E:\\admin.xlsx", NULL); - - size_t rowCount = iKXiao::Ins().GetRowCount(wb, IDX_SHEET_CUR); - for (size_t r = 0; r < rowCount; r++) + WorkBook* wb = iKXiao::Ins().OpenExcel("admin.xlsx", NULL); + if (wb) { - size_t columnCount = 0; - char* rowData = iKXiao::Ins().GetRowStringArray(wb, IDX_SHEET_CUR, r, &columnCount); - size_t offset = 0; - for (size_t c = 0; c < columnCount; c++) + WorkSheet* sheet = wb->OpenCurrentSheet(); + if (sheet) { - std::cout << rowData + offset << ","; - offset += strlen(rowData + offset) + 1; + size_t rowCount = sheet->GetRowCount(); + for (size_t r = 0; r < rowCount; r++) + { + size_t columnCount = 0; + char* rowData = sheet->GetRowStringArray(r, &columnCount); + size_t offset = 0; + for (size_t c = 0; c < columnCount; c++) + { + std::cout << rowData + offset << ","; + offset += strlen(rowData + offset) + 1; + } + sheet->FreeString(rowData); + std::cout << std::endl; + } + + Cell* cell = sheet->OpenCell(0, 0); + if (cell) + { + cell->SetStringValue("我爱你mensong"); + std::string cellstr = cell->GetStringValue(""); + std::cout << "(0,0) = " << cellstr << std::endl; + sheet->CloseCell(cell); + } + + + cell = sheet->OpenCell("A1"); + if (cell) + { + std::string cellstr = cell->GetStringValue(""); + std::cout << "A1 = " << cellstr << std::endl; + sheet->CloseCell(cell); + } + + cell = sheet->OpenCell("A2"); + if (cell) + { + cell->SetFormula("=SUM(1,2,3)"); + int intVal = cell->GetIntValue(0); + std::cout << "=SUM(1,2,3) = " << intVal << std::endl; + sheet->CloseCell(cell); + } + + wb->CloseSheet(sheet); } - iKXiao::Ins().FreeString(wb, rowData); - std::cout << std::endl; + + wb->Save("admin1.xlsx"); + + iKXiao::Ins().CloseExcel(wb); } - +} - char* cellStr = iKXiao::Ins().GetCellStringValue(wb, IDX_SHEET_CUR, 0, 0); - char* cellStr1 = iKXiao::Ins().GetCellStringValueByRefName(wb, IDX_SHEET_CUR, "A1"); +void testConfig() +{ + WorkBook* wb = iKXiao::Ins().OpenExcel("config.xlsx", NULL); + if (wb) + { + WorkSheet* sheet = wb->OpenCurrentSheet(); + if (sheet) + { + size_t idxRowStart = sheet->GetNotEmptyRowStart(); + size_t idxRowEnd = sheet->GetNotEmptyRowEnd(); + size_t idxColumnStart = sheet->GetNotEmptyColumnStart(); + size_t idxColumnEnd = sheet->GetNotEmptyColumnEnd(); + for (size_t r = idxRowStart; r <= idxRowEnd; r++) + { + for (size_t c = idxColumnStart; c <= idxColumnEnd; c++) + { + Cell* cell = sheet->OpenCell(r, c); + if (cell) + { + auto type = cell->GetValueType(); + switch (type) + { + case Cell::empty_value: + std::cout << "" << ','; + break; + case Cell::boolean_value: + std::cout << cell->GetBoolValue() << ','; + break; + case Cell::date_value: + { + int year = 0; + int month = 0; + int day = 0; + cell->GetDateValue(year, month, day); + std::cout << year << "å¹´" << month << "月" << day << "æ—¥" << ','; + break; + } + case Cell::error_value: + std::cout << "#VALUE!" << ','; + break; + case Cell::inline_string_value: + case Cell::shared_string_value: + std::cout << cell->GetStringValue() << ','; + break; + case Cell::number_value: + std::cout << cell->GetDoubleValue() << ','; + break; + case Cell::formula_string_value: + std::cout << cell->GetDoubleValue() << ','; + break; + default: + std::cout << cell->GetStringValue() << ','; + break; + } + + sheet->CloseCell(cell); + } + } + std::cout << std::endl; + } - iKXiao::Ins().SetCellStringValue(wb, IDX_SHEET_CUR, 0, 0, "我爱你mensong"); - iKXiao::Ins().SetCellFormula(wb, IDX_SHEET_CUR, 0, 1, "=SUM(1,2,3)"); - auto type = iKXiao::Ins().GetCellType(wb, IDX_SHEET_CUR, 0, 1); - char* formulaValue = iKXiao::Ins().GetCellStringValue(wb, IDX_SHEET_CUR, 0, 1); + wb->CloseSheet(sheet); + } - iKXiao::Ins().SaveExcel(wb, "E:\\admin1.xlsx", NULL); + iKXiao::Ins().CloseExcel(wb); + } +} + +int main() +{ + normalTest(); + + std::cout << std::endl << std::endl; + + testConfig(); - iKXiao::Ins().CloseExcel(wb); return 0; } diff --git a/Test_iKXiao/Test_iKXiao.vcxproj b/Test_iKXiao/Test_iKXiao.vcxproj index bf2f811..7da1d43 100644 --- a/Test_iKXiao/Test_iKXiao.vcxproj +++ b/Test_iKXiao/Test_iKXiao.vcxproj @@ -70,6 +70,20 @@ + + tmp\$(Platform)\$(Configuration)\ + + + tmp\$(Platform)\$(Configuration)\ + + + tmp\$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + + + tmp\$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + Level3 diff --git a/iKXiao/iKXiao.cpp b/iKXiao/iKXiao.cpp index aa6afa5..2736368 100644 --- a/iKXiao/iKXiao.cpp +++ b/iKXiao/iKXiao.cpp @@ -5,544 +5,450 @@ #include #include -class iKXiaoImp +static bool IsPathExist(const char* path) +{ + int nRet = _access(path, 0); + return 0 == nRet || EACCES == nRet; +} + + +//½«Ansi×Ö·ûת»»ÎªUnicode×Ö·û´® +static std::wstring AnsiToUnicode(const std::string& multiByteStr) +{ + wchar_t* pWideCharStr; //¶¨Òå·µ»ØµÄ¿í×Ö·ûÖ¸Õë + int nLenOfWideCharStr; //±£´æ¿í×Ö·û¸öÊý£¬×¢Òâ²»ÊÇ×Ö½ÚÊý + const char* pMultiByteStr = multiByteStr.c_str(); + //»ñÈ¡¿í×Ö·ûµÄ¸öÊý + nLenOfWideCharStr = MultiByteToWideChar(CP_ACP, 0, pMultiByteStr, -1, NULL, 0); + //»ñµÃ¿í×Ö·ûÖ¸Õë + pWideCharStr = (wchar_t*)(HeapAlloc(GetProcessHeap(), 0, nLenOfWideCharStr * sizeof(wchar_t))); + MultiByteToWideChar(CP_ACP, 0, pMultiByteStr, -1, pWideCharStr, nLenOfWideCharStr); + //·µ»Ø + std::wstring wideByteRet(pWideCharStr, nLenOfWideCharStr); + //Ïú»ÙÄÚ´æÖеÄ×Ö·û´® + HeapFree(GetProcessHeap(), 0, pWideCharStr); + return wideByteRet.c_str(); +} + +//½«Unicode×Ö·ûת»»ÎªAnsi×Ö·û´® +static std::string UnicodeToAnsi(const std::wstring& wideByteStr) +{ + char* pMultiCharStr; //¶¨Òå·µ»ØµÄ¶à×Ö·ûÖ¸Õë + int nLenOfMultiCharStr; //±£´æ¶à×Ö·û¸öÊý£¬×¢Òâ²»ÊÇ×Ö½ÚÊý + const wchar_t* pWideByteStr = wideByteStr.c_str(); + //»ñÈ¡¶à×Ö·ûµÄ¸öÊý + nLenOfMultiCharStr = WideCharToMultiByte(CP_ACP, 0, pWideByteStr, -1, NULL, 0, NULL, NULL); + //»ñµÃ¶à×Ö·ûÖ¸Õë + pMultiCharStr = (char*)(HeapAlloc(GetProcessHeap(), 0, nLenOfMultiCharStr * sizeof(char))); + WideCharToMultiByte(CP_ACP, 0, pWideByteStr, -1, pMultiCharStr, nLenOfMultiCharStr, NULL, NULL); + //·µ»Ø + std::string sRet(pMultiCharStr, nLenOfMultiCharStr); + //Ïú»ÙÄÚ´æÖеÄ×Ö·û´® + HeapFree(GetProcessHeap(), 0, pMultiCharStr); + return sRet.c_str(); +} + +static std::string UnicodeToUtf8(const std::wstring& wideByteStr) +{ + int len = WideCharToMultiByte(CP_UTF8, 0, wideByteStr.c_str(), -1, NULL, 0, NULL, NULL); + char* szUtf8 = new char[len + 1]; + memset(szUtf8, 0, len + 1); + WideCharToMultiByte(CP_UTF8, 0, wideByteStr.c_str(), -1, szUtf8, len, NULL, NULL); + std::string s = szUtf8; + delete[] szUtf8; + return s.c_str(); +} + +static std::wstring Utf8ToUnicode(const std::string& utf8Str) +{ + //Ԥת»»£¬µÃµ½ËùÐè¿Õ¼äµÄ´óС; + int wcsLen = ::MultiByteToWideChar(CP_UTF8, NULL, utf8Str.c_str(), strlen(utf8Str.c_str()), NULL, 0); + //·ÖÅä¿Õ¼äÒª¸ø'\0'Áô¸ö¿Õ¼ä£¬MultiByteToWideChar²»»á¸ø'\0'¿Õ¼ä + wchar_t* wszString = new wchar_t[wcsLen + 1]; + //ת»» + ::MultiByteToWideChar(CP_UTF8, NULL, utf8Str.c_str(), strlen(utf8Str.c_str()), wszString, wcsLen); + //×îºó¼ÓÉÏ'\0' + wszString[wcsLen] = '\0'; + std::wstring s(wszString); + delete[] wszString; + return s; +} + +static std::string AnsiToUtf8(const std::string& multiByteStr) +{ + std::wstring ws = AnsiToUnicode(multiByteStr); + return UnicodeToUtf8(ws); +} + +static std::string Utf8ToAnsi(const std::string& utf8Str) +{ + std::wstring ws = Utf8ToUnicode(utf8Str); + return UnicodeToAnsi(ws); +} + +class BufferManager { public: - iKXiaoImp() + BufferManager() { } - ~iKXiaoImp() + virtual ~BufferManager() { for (auto it = m_stringCache.begin(); it != m_stringCache.end(); ++it) { - delete[] (*it); + delete[](*it); } m_stringCache.clear(); } - - IK_WORKBOOK Open(const char* xlsxFilepath, const char* password) - { - //set data - m_filepath = xlsxFilepath; - if (password && password[0] != '\0') - { - m_password = password; - } - - try - { - //if the file path exist,load the file to workbook - if (IsPathExist(xlsxFilepath)) - { - if (m_password.empty()) - m_workbook.load(xlnt::path(xlsxFilepath)); - else - m_workbook.load(xlnt::path(xlsxFilepath), m_password); - } - } - catch (const std::exception&) - { - return NULL; - } - - return this; - } - - int GetSheetCount() +public: + char* allocStringBuffer(int size) { - return (int)m_workbook.sheet_count(); + char* buff = new char[size]; + m_stringCache.insert(buff); + return buff; } - - int GetSheetIndexByTitle(const char* sheetTitle) + void freeStringBuffer(char* buff) { - auto titles = m_workbook.sheet_titles(); - for (size_t i = 0; i < titles.size(); i++) + if (!buff) + return; + auto itFinder = m_stringCache.find(buff); + if (itFinder != m_stringCache.end()) { - if (titles[i] == sheetTitle) - return i; + m_stringCache.erase(itFinder); + delete[] buff; } - return -1; } - char* GetSheetTitle(int sheetIndex) + char* moveStringBuffer(const std::string& innerStr) { - try - { - auto sheet = getSheetByIndex(sheetIndex); - return moveStringBuffer(sheet.title()); - } - catch (const std::exception&) - { - return NULL; - } + char* buff = allocStringBuffer(innerStr.size() + 1); + memcpy(buff, &innerStr[0], innerStr.size()); + buff[innerStr.size()] = '\0'; + return buff; } - bool SetCurrentSheet(int sheetIndex) +protected: + std::set m_stringCache; +}; + +class LastError +{ +public: + LastError() { - if (sheetIndex < 0 && sheetIndex >= GetSheetCount()) - return false; - try - { - m_workbook.active_sheet(sheetIndex); - return true; - } - catch (const std::exception&) - { - return false; - } } - //atIndex==-1ʱÔÚ×îºó´´½¨ - int CreateSheet(int atIndex = -1) + virtual void SetLastError(const std::string& lastError) { - try - { - if (atIndex < 0) - { - m_workbook.create_sheet(); - return GetSheetCount() - 1; - } - else - { - m_workbook.create_sheet((size_t)atIndex); - return atIndex; - } - } - catch (const std::exception&) - { - return -1; - } + m_lastError = lastError; } - int CopySheet(int srcIndex, int atIndex = -1) + virtual const char* GetLastError() { - try - { - auto sheet = getSheetByIndex(srcIndex); - - if (atIndex < 0) - { - m_workbook.copy_sheet(sheet); - return GetSheetCount() - 1; - } - else - { - m_workbook.copy_sheet(sheet, (size_t)atIndex); - return atIndex; - } - } - catch (const std::exception&) - { - return -1; - } + return m_lastError.c_str(); } - bool RemoveSheet(int sheetIndex) + virtual void ClearLastError() { - try - { - auto sheet = getSheetByIndex(sheetIndex); - m_workbook.remove_sheet(sheet); - return true; - } - catch (const std::exception&) - { - return false; - } + m_lastError.clear(); } - bool SetSheetTitle(int sheetIndex, const char* title) - { - try - { - auto sheet = getSheetByIndex(sheetIndex); - sheet.title(title); - return true; - } - catch (const std::exception&) - { - return false; - } - } +private: + std::string m_lastError; +}; - size_t GetRowCount(int sheetIndex) +class CellImp + : public Cell + , public BufferManager + , public LastError +{ +public: + CellImp(const xlnt::cell& cell) + : m_cell(cell) { - try - { - auto sheet = getSheetByIndex(sheetIndex); - auto rows = sheet.rows(false); - return rows.length(); - } - catch (const std::exception&) - { - return 0; - } - } - char* GetRowStringArray(int sheetIndex, size_t rowIndex, size_t* columnCount) + } + ~CellImp() { - try - { - auto sheet = getSheetByIndex(sheetIndex); - auto rows = sheet.rows(false); - if (rowIndex >= rows.length()) - { - columnCount = 0; - return NULL; - } - auto row = rows[rowIndex]; - std::vector rowData; - size_t totalSize = 0; - for (auto cell : row) - { - rowData.push_back(Utf8ToAnsi(cell.to_string())); - totalSize += rowData[rowData.size() - 1].size() + 1; - } - char* totalBuff = allocStringBuffer(totalSize); - size_t start = 0; - for (size_t i = 0; i < rowData.size(); i++) - { - strcpy_s(totalBuff + start, totalSize - start, rowData[i].c_str()); - (totalBuff + start)[rowData[i].size()] = '\0'; - start += rowData[i].size() + 1; - } - *columnCount = rowData.size(); - return totalBuff; - } - catch (const std::exception&) - { - columnCount = 0; - return NULL; - } + } - CellType GetCellType(int sheetIndex, size_t rowIndex, size_t columnIndex) + xlnt::cell& raw() { - try - { - auto sheet = getSheetByIndex(sheetIndex); - auto cell = sheet.cell(xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1)); - return (CellType)cell.data_type(); - } - catch (const std::exception&) - { - return CellType::empty_value; - } + return m_cell; } - char* GetCellStringValue(int sheetIndex, size_t rowIndex, size_t columnIndex) +public: + virtual CellType GetValueType() override { try { - auto sheet = getSheetByIndex(sheetIndex); - auto cell = sheet.cell(xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1)); - return moveStringBuffer(Utf8ToAnsi(cell.to_string())); + return (CellType)m_cell.data_type(); } - catch (const std::exception&) + catch (const std::exception& ex) { - return NULL; + SetLastError(ex.what()); + return CellType::empty_value; } } - char* GetCellStringValueByRefName(int sheetIndex, const char* refName) + virtual char* GetStringValue(const char* defVal = "") override { try { - auto sheet = getSheetByIndex(sheetIndex); - auto cell = sheet.cell(refName); - return moveStringBuffer(Utf8ToAnsi(cell.to_string())); + return moveStringBuffer(Utf8ToAnsi(m_cell.to_string())); } - catch (const std::exception&) + catch (const std::exception& ex) { - return NULL; + SetLastError(ex.what()); + return const_cast(defVal); } } - bool SetCellStringValue(int sheetIndex, size_t rowIndex, size_t columnIndex, const char* strVal) + virtual bool SetStringValue(const char* strVal) override { try { - auto sheet = getSheetByIndex(sheetIndex); - sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(AnsiToUtf8(strVal)); + m_cell.value(AnsiToUtf8(strVal)); return true; } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return false; } } - bool SetCellNullValue(int sheetIndex, size_t rowIndex, size_t columnIndex) + virtual bool SetNullValue() override { try { - auto sheet = getSheetByIndex(sheetIndex); - sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).clear_value(); + m_cell.clear_value(); return true; } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return false; } } - bool SetCellBoolValue(int sheetIndex, size_t rowIndex, size_t columnIndex, bool boolean_value) + virtual bool SetBoolValue(bool boolean_value) override { try { - auto sheet = getSheetByIndex(sheetIndex); - sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(boolean_value); + m_cell.value(boolean_value); return true; } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return false; } } - bool GetCellBoolValue(int sheetIndex, size_t rowIndex, size_t columnIndex, bool defVal = false) + virtual bool GetBoolValue(bool defVal) override { try { - auto sheet = getSheetByIndex(sheetIndex); - return sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(); + return m_cell.value(); } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return defVal; } } - bool SetCellIntValue(int sheetIndex, size_t rowIndex, size_t columnIndex, int int_value) + virtual bool SetIntValue(int int_value) override { try { - auto sheet = getSheetByIndex(sheetIndex); - sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(int_value); + m_cell.value(int_value); return true; } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return false; } } - int GetCellIntValue(int sheetIndex, size_t rowIndex, size_t columnIndex, int defVal = 0) + virtual int GetIntValue(int defVal) override { try { - auto sheet = getSheetByIndex(sheetIndex); - return sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(); + return m_cell.value(); } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return defVal; } } - bool SetCellUIntValue(int sheetIndex, size_t rowIndex, size_t columnIndex, unsigned int int_value) + virtual bool SetUIntValue(unsigned int int_value) override { try { - auto sheet = getSheetByIndex(sheetIndex); - sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(int_value); + m_cell.value(int_value); return true; } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return false; } } - unsigned int GetCellUIntValue(int sheetIndex, size_t rowIndex, size_t columnIndex, unsigned int defVal = 0) + virtual unsigned int GetUIntValue(unsigned int defVal) override { try { - auto sheet = getSheetByIndex(sheetIndex); - return sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(); + return m_cell.value(); } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return defVal; } } - bool SetCellLLIntValue(int sheetIndex, size_t rowIndex, size_t columnIndex, long long int int_value) + virtual bool SetLLIntValue(long long int int_value) override { try { - auto sheet = getSheetByIndex(sheetIndex); - sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(int_value); + m_cell.value(int_value); return true; } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return false; } } - long long int GetCellLLIntValue(int sheetIndex, size_t rowIndex, size_t columnIndex, long long int defVal = 0) + virtual long long int GetLLIntValue(long long int defVal) override { try { - auto sheet = getSheetByIndex(sheetIndex); - return sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(); + return m_cell.value(); } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return defVal; } } - bool SetCellULLIntValue(int sheetIndex, size_t rowIndex, size_t columnIndex, unsigned long long int int_value) + virtual bool SetULLIntValue(unsigned long long int int_value) override { try { - auto sheet = getSheetByIndex(sheetIndex); - sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(int_value); + m_cell.value(int_value); return true; } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return false; } } - unsigned long long int GetCellULLIntValue(int sheetIndex, size_t rowIndex, size_t columnIndex, unsigned long long int defVal = 0) + virtual unsigned long long int GetULLIntValue(unsigned long long int defVal) override { try { - auto sheet = getSheetByIndex(sheetIndex); - return sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(); + return m_cell.value(); } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return defVal; } } - bool SetCellDoubleValue(int sheetIndex, size_t rowIndex, size_t columnIndex, double float_value) + virtual bool SetDoubleValue(double float_value) override { try { - auto sheet = getSheetByIndex(sheetIndex); - sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(float_value); + m_cell.value(float_value); return true; } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return false; } } - double GetCellDoubleValue(int sheetIndex, size_t rowIndex, size_t columnIndex, double defVal = 0.0) + virtual double GetDoubleValue(double defVal) override { try { - auto sheet = getSheetByIndex(sheetIndex); - return sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(); + return m_cell.value(); } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return defVal; } } - bool SetCellDateValue(int sheetIndex, size_t rowIndex, size_t columnIndex, - int year_, int month_, int day_) + virtual bool SeDateValue(int year_, int month_, int day_) override { try { - auto sheet = getSheetByIndex(sheetIndex); xlnt::date d(year_, month_, day_); - sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(d); + m_cell.value(d); return true; } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return false; } } - bool GetCellDateValue(int sheetIndex, size_t rowIndex, size_t columnIndex, - int& year_, int& month_, int& day_) + virtual bool GetDateValue(int& year_, int& month_, int& day_) override { try { - auto sheet = getSheetByIndex(sheetIndex); - xlnt::date d = sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(); + xlnt::date d = m_cell.value(); year_ = d.year; month_ = d.month; day_ = d.day; return true; } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return false; } } - bool SetCellDatetimeValue(int sheetIndex, size_t rowIndex, size_t columnIndex, - int year_, int month_, int day_, int hour_ = 0, int minute_ = 0, int second_ = 0, int microsecond_ = 0) + virtual bool SetDatetimeValue(int year_, int month_, int day_, int hour_, int minute_, int second_, int microsecond_) override { try { - auto sheet = getSheetByIndex(sheetIndex); xlnt::datetime d(year_, month_, day_, hour_, minute_, second_, microsecond_); - sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(d); + m_cell.value(d); return true; } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return false; } } - bool GetCellDatetimeValue(int sheetIndex, size_t rowIndex, size_t columnIndex, - int& year_, int& month_, int& day_, int& hour_, int& minute_, int& second_, int& microsecond_) + virtual bool GetDatetimeValue(int& year_, int& month_, int& day_, int& hour_, int& minute_, int& second_, int& microsecond_) override { try { - auto sheet = getSheetByIndex(sheetIndex); - xlnt::datetime d = sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(); + xlnt::datetime d = m_cell.value(); year_ = d.year; month_ = d.month; day_ = d.day; @@ -552,78 +458,66 @@ class iKXiaoImp microsecond_ = d.microsecond; return true; } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return false; } } - bool SetCellTimeValue(int sheetIndex, size_t rowIndex, size_t columnIndex, - int hour_ = 0, int minute_ = 0, int second_ = 0, int microsecond_ = 0) - { + virtual bool SetTimeValue(int hour_, int minute_, int second_, int microsecond_) override + { try { - auto sheet = getSheetByIndex(sheetIndex); xlnt::time t(hour_, minute_, second_, microsecond_); - sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(t); + m_cell.value(t); return true; } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return false; } } - bool GetCellTimeValue(int sheetIndex, size_t rowIndex, size_t columnIndex, - int& hour_, int& minute_, int& second_, int& microsecond_) + virtual bool GetTimeValue(int& hour_, int& minute_, int& second_, int& microsecond_) override { try { - auto sheet = getSheetByIndex(sheetIndex); - xlnt::time d = sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(); + xlnt::time d = m_cell.value(); hour_ = d.hour; minute_ = d.minute; second_ = d.second; microsecond_ = d.microsecond; return true; } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return false; } } - bool SetCellTimeDeltaValue(int sheetIndex, size_t rowIndex, size_t columnIndex, - int days_, int hours_, int minutes_, int seconds_, int microseconds_) + virtual bool SetTimeDeltaValue(int days_, int hours_, int minutes_, int seconds_, int microseconds_) override { try { - auto sheet = getSheetByIndex(sheetIndex); xlnt::timedelta t(days_, hours_, minutes_, seconds_, microseconds_); - sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(t); + m_cell.value(t); return true; } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return false; } } - bool GetCellTimeDeltaValue(int sheetIndex, size_t rowIndex, size_t columnIndex, - int days_, int& hours_, int& minutes_, int& seconds_, int& microseconds_) + virtual bool GetTimeDeltaValue(int days_, int& hours_, int& minutes_, int& seconds_, int& microseconds_) override { try { - auto sheet = getSheetByIndex(sheetIndex); - xlnt::timedelta d = sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).value(); + xlnt::timedelta d = m_cell.value(); days_ = d.days; hours_ = d.hours; minutes_ = d.minutes; @@ -631,443 +525,492 @@ class iKXiaoImp microseconds_ = d.microseconds; return true; } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return false; } } - bool SetCellFormula(int sheetIndex, size_t rowIndex, size_t columnIndex, const char* formula) + virtual bool SetFormula(const char* formula) override { try { - auto sheet = getSheetByIndex(sheetIndex); - sheet.cell( - xlnt::column_t(columnIndex + 1), xlnt::row_t(rowIndex + 1) - ).formula(formula); + m_cell.formula(formula); return true; } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return false; } } - bool CopyCell(int sheetIndex, size_t fromRowIndex, size_t fromColumnIndex, size_t toRowIndex, size_t toColumnIndex) + virtual bool CopyFrom(Cell* otherCell) override { try { - auto sheet = getSheetByIndex(sheetIndex); - xlnt::cell c = sheet.cell( - xlnt::column_t(fromColumnIndex + 1), xlnt::row_t(fromRowIndex + 1)); - sheet.cell( - xlnt::column_t(toColumnIndex + 1), xlnt::row_t(toRowIndex + 1) - ).value(c); + CellImp* imp = (CellImp*)otherCell; + m_cell.value(imp->raw()); return true; } - catch (const std::exception&) + catch (const std::exception& ex) { + SetLastError(ex.what()); return false; } } - bool Save(const char* filepath, const char* password) + virtual void FreeString(char* buff) override { - try - { - if (!password || password[0] == '\0') - m_workbook.save(xlnt::path(filepath)); - else - m_workbook.save(xlnt::path(filepath), password); - return true; - } - catch (const std::exception&) - { - return false; - } + freeStringBuffer(buff); } +private: + xlnt::cell m_cell; +}; + +class WorkSheetImp + : public WorkSheet + , public BufferManager + , public LastError +{ public: - static bool IsPathExist(const char* path) + WorkSheetImp(xlnt::worksheet& sheet) + : m_sheet(sheet) { - int nRet = _access(path, 0); - return 0 == nRet || EACCES == nRet; - } + } - //½«Ansi×Ö·ûת»»ÎªUnicode×Ö·û´® - static std::wstring AnsiToUnicode(const std::string& multiByteStr) + xlnt::worksheet& raw() { - wchar_t* pWideCharStr; //¶¨Òå·µ»ØµÄ¿í×Ö·ûÖ¸Õë - int nLenOfWideCharStr; //±£´æ¿í×Ö·û¸öÊý£¬×¢Òâ²»ÊÇ×Ö½ÚÊý - const char* pMultiByteStr = multiByteStr.c_str(); - //»ñÈ¡¿í×Ö·ûµÄ¸öÊý - nLenOfWideCharStr = MultiByteToWideChar(CP_ACP, 0, pMultiByteStr, -1, NULL, 0); - //»ñµÃ¿í×Ö·ûÖ¸Õë - pWideCharStr = (wchar_t*)(HeapAlloc(GetProcessHeap(), 0, nLenOfWideCharStr * sizeof(wchar_t))); - MultiByteToWideChar(CP_ACP, 0, pMultiByteStr, -1, pWideCharStr, nLenOfWideCharStr); - //·µ»Ø - std::wstring wideByteRet(pWideCharStr, nLenOfWideCharStr); - //Ïú»ÙÄÚ´æÖеÄ×Ö·û´® - HeapFree(GetProcessHeap(), 0, pWideCharStr); - return wideByteRet.c_str(); + return m_sheet; } - //½«Unicode×Ö·ûת»»ÎªAnsi×Ö·û´® - static std::string UnicodeToAnsi(const std::wstring& wideByteStr) +public: + virtual char* GetSheetTitle() override { - char* pMultiCharStr; //¶¨Òå·µ»ØµÄ¶à×Ö·ûÖ¸Õë - int nLenOfMultiCharStr; //±£´æ¶à×Ö·û¸öÊý£¬×¢Òâ²»ÊÇ×Ö½ÚÊý - const wchar_t* pWideByteStr = wideByteStr.c_str(); - //»ñÈ¡¶à×Ö·ûµÄ¸öÊý - nLenOfMultiCharStr = WideCharToMultiByte(CP_ACP, 0, pWideByteStr, -1, NULL, 0, NULL, NULL); - //»ñµÃ¶à×Ö·ûÖ¸Õë - pMultiCharStr = (char*)(HeapAlloc(GetProcessHeap(), 0, nLenOfMultiCharStr * sizeof(char))); - WideCharToMultiByte(CP_ACP, 0, pWideByteStr, -1, pMultiCharStr, nLenOfMultiCharStr, NULL, NULL); - //·µ»Ø - std::string sRet(pMultiCharStr, nLenOfMultiCharStr); - //Ïú»ÙÄÚ´æÖеÄ×Ö·û´® - HeapFree(GetProcessHeap(), 0, pMultiCharStr); - return sRet.c_str(); + try + { + return moveStringBuffer(m_sheet.title()); + } + catch (const std::exception& ex) + { + SetLastError(ex.what()); + return NULL; + } } - static std::string UnicodeToUtf8(const std::wstring& wideByteStr) + virtual bool SetSheetTitle(const char* title) override { - int len = WideCharToMultiByte(CP_UTF8, 0, wideByteStr.c_str(), -1, NULL, 0, NULL, NULL); - char* szUtf8 = new char[len + 1]; - memset(szUtf8, 0, len + 1); - WideCharToMultiByte(CP_UTF8, 0, wideByteStr.c_str(), -1, szUtf8, len, NULL, NULL); - std::string s = szUtf8; - delete[] szUtf8; - return s.c_str(); + try + { + m_sheet.title(title); + return true; + } + catch (const std::exception& ex) + { + SetLastError(ex.what()); + return false; + } } - static std::wstring Utf8ToUnicode(const std::string& utf8Str) + virtual size_t GetRowCount() override { - //Ԥת»»£¬µÃµ½ËùÐè¿Õ¼äµÄ´óС; - int wcsLen = ::MultiByteToWideChar(CP_UTF8, NULL, utf8Str.c_str(), strlen(utf8Str.c_str()), NULL, 0); - //·ÖÅä¿Õ¼äÒª¸ø'\0'Áô¸ö¿Õ¼ä£¬MultiByteToWideChar²»»á¸ø'\0'¿Õ¼ä - wchar_t* wszString = new wchar_t[wcsLen + 1]; - //ת»» - ::MultiByteToWideChar(CP_UTF8, NULL, utf8Str.c_str(), strlen(utf8Str.c_str()), wszString, wcsLen); - //×îºó¼ÓÉÏ'\0' - wszString[wcsLen] = '\0'; - std::wstring s(wszString); - delete[] wszString; - return s; + try + { + xlnt::range range = m_sheet.rows(false); + return range.length(); + } + catch (const std::exception& ex) + { + SetLastError(ex.what()); + return 0; + } } - static std::string AnsiToUtf8(const std::string& multiByteStr) + virtual size_t GetColumnCount() override { - std::wstring ws = AnsiToUnicode(multiByteStr); - return UnicodeToUtf8(ws); + try + { + xlnt::range range = m_sheet.columns(false); + return range.length(); + } + catch (const std::exception& ex) + { + SetLastError(ex.what()); + return 0; + } } - static std::string Utf8ToAnsi(const std::string& utf8Str) + virtual size_t GetNotEmptyRowStart() override { - std::wstring ws = Utf8ToUnicode(utf8Str); - return UnicodeToAnsi(ws); + try + { + return m_sheet.lowest_row() - 1; + } + catch (const std::exception& ex) + { + SetLastError(ex.what()); + return 0; + } } -public: - - char* allocStringBuffer(int size) + virtual size_t GetNotEmptyRowEnd() override { - char* buff = new char[size]; - m_stringCache.insert(buff); - return buff; + try + { + return m_sheet.highest_row() - 1; + } + catch (const std::exception& ex) + { + SetLastError(ex.what()); + return 0; + } } - void freeStringBuffer(char* buff) + + virtual size_t GetNotEmptyColumnStart() override { - if (!buff) - return; - m_stringCache.erase(buff); - delete[] buff; + try + { + return m_sheet.lowest_column().index - 1; + } + catch (const std::exception& ex) + { + SetLastError(ex.what()); + return 0; + } } - char* moveStringBuffer(const std::string& innerStr) + virtual size_t GetNotEmptyColumnEnd() override { - char* buff = allocStringBuffer(innerStr.size() + 1); - memcpy(buff, &innerStr[0], innerStr.size()); - buff[innerStr.size()] = '\0'; - return buff; + try + { + return m_sheet.highest_column().index - 1; + } + catch (const std::exception& ex) + { + SetLastError(ex.what()); + return 0; + } } - xlnt::worksheet getSheetByIndex(int sheetIndex) + virtual char* GetRowStringArray(size_t rowIndex, size_t* columnCount) override { try { - switch (sheetIndex) + xlnt::range rows = m_sheet.rows(false); + if (rowIndex >= rows.length()) + { + columnCount = 0; + return NULL; + } + xlnt::cell_vector row = rows[rowIndex]; + std::vector rowData; + size_t totalSize = 0; + for (auto cell : row) + { + rowData.push_back(Utf8ToAnsi(cell.to_string())); + totalSize += rowData[rowData.size() - 1].size() + 1; + } + char* totalBuff = allocStringBuffer(totalSize); + size_t start = 0; + for (size_t i = 0; i < rowData.size(); i++) { - case -1: - return m_workbook.active_sheet(); - case -2: - return m_workbook.sheet_by_index(m_workbook.sheet_count() - 1); - default: - return m_workbook.sheet_by_index(sheetIndex); - break; + strcpy_s(totalBuff + start, totalSize - start, rowData[i].c_str()); + (totalBuff + start)[rowData[i].size()] = '\0'; + start += rowData[i].size() + 1; } + *columnCount = rowData.size(); + return totalBuff; } - catch (const std::exception&) + catch (const std::exception& ex) { - return m_workbook.active_sheet(); + SetLastError(ex.what()); + columnCount = 0; + return NULL; } } -private: - std::set m_stringCache; + virtual Cell* OpenCell(size_t rowIdx, int columnIdx) override + { + try + { + xlnt::cell cell = m_sheet.cell(xlnt::column_t(columnIdx + 1), xlnt::row_t(rowIdx + 1)); + CellImp* imp = new CellImp(cell); + return imp; + } + catch (const std::exception& ex) + { + SetLastError(ex.what()); + return NULL; + } + } -private: - xlnt::workbook m_workbook; - std::string m_filepath; - std::string m_password; -}; + virtual Cell* OpenCell(const char* refName) override + { + try + { + xlnt::cell cell = m_sheet.cell(refName); + CellImp* imp = new CellImp(cell); + return imp; + } + catch (const std::exception& ex) + { + SetLastError(ex.what()); + return NULL; + } + } -IKXIAO_API IK_WORKBOOK OpenExcel(const char* xlsxFilepath, const char* password) -{ - iKXiaoImp* imp = new iKXiaoImp(); - IK_WORKBOOK ret = imp->Open(xlsxFilepath, password); - if (!ret) + virtual void CloseCell(Cell* cell) override + { + if (!cell) + return; + CellImp* imp = (CellImp*)cell; delete imp; - return ret; -} - -IKXIAO_API int GetSheetCount(IK_WORKBOOK workbook) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->GetSheetCount(); -} - -IKXIAO_API int GetSheetIndexByTitle(IK_WORKBOOK workbook, const char* sheetTitle) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->GetSheetIndexByTitle(sheetTitle); -} - -IKXIAO_API char* GetSheetTitle(IK_WORKBOOK workbook, int sheetIndex) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->GetSheetTitle(sheetIndex); -} - -IKXIAO_API bool SetCurrentSheet(IK_WORKBOOK workbook, int sheetIndex) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->SetCurrentSheet(sheetIndex); -} - -IKXIAO_API int CreateSheet(IK_WORKBOOK workbook, int atIndex) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->CreateSheet(atIndex); -} - -IKXIAO_API int CopySheet(IK_WORKBOOK workbook, int srcIndex, int atIndex) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->CopySheet(srcIndex, atIndex); -} - -IKXIAO_API bool RemoveSheet(IK_WORKBOOK workbook, int sheetIndex) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->RemoveSheet(sheetIndex); -} - -IKXIAO_API bool SetSheetTitle(IK_WORKBOOK workbook, int sheetIndex, const char* title) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->SetSheetTitle(sheetIndex, title); -} - -IKXIAO_API size_t GetRowCount(IK_WORKBOOK workbook, int sheetIndex) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->GetRowCount(sheetIndex); -} - -IKXIAO_API char* GetRowStringArray(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t* columnCount) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->GetRowStringArray(sheetIndex, rowIndex, columnCount); -} - -IKXIAO_API CellType GetCellType(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->GetCellType(sheetIndex, rowIndex, columnIndex); -} - -IKXIAO_API char* GetCellStringValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->GetCellStringValue(sheetIndex, rowIndex, columnIndex); -} - -IKXIAO_API char* GetCellStringValueByRefName(IK_WORKBOOK workbook, int sheetIndex, const char* refName) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->GetCellStringValueByRefName(sheetIndex, refName); -} - -IKXIAO_API bool SetCellStringValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, const char* strVal) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->SetCellStringValue(sheetIndex, rowIndex, columnIndex, strVal); -} - -IKXIAO_API bool SetCellNullValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->SetCellNullValue(sheetIndex, rowIndex, columnIndex); -} - -IKXIAO_API bool SetCellBoolValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, bool boolean_value) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->SetCellBoolValue(sheetIndex, rowIndex, columnIndex, boolean_value); -} - -IKXIAO_API bool GetCellBoolValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, bool defVal) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->GetCellBoolValue(sheetIndex, rowIndex, columnIndex, defVal); -} - -IKXIAO_API bool SetCellIntValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int int_value) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->SetCellIntValue(sheetIndex, rowIndex, columnIndex, int_value); -} - -IKXIAO_API int GetCellIntValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int defVal) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->GetCellIntValue(sheetIndex, rowIndex, columnIndex, defVal); -} + } -IKXIAO_API bool SetCellUIntValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, unsigned int int_value) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->SetCellUIntValue(sheetIndex, rowIndex, columnIndex, int_value); -} + virtual void FreeString(char* buff) override + { + freeStringBuffer(buff); + } -IKXIAO_API unsigned int GetCellUIntValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, unsigned int defVal) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->GetCellUIntValue(sheetIndex, rowIndex, columnIndex, defVal); -} +private: + xlnt::worksheet m_sheet; +}; -IKXIAO_API bool SetCellLLIntValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, long long int int_value) +class WorkBookImp + : public WorkBook + , public BufferManager + , public LastError { - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->SetCellLLIntValue(sheetIndex, rowIndex, columnIndex, int_value); -} +public: + ~WorkBookImp() + { + + } -IKXIAO_API long long int GetCellLLIntValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, long long int defVal) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->GetCellLLIntValue(sheetIndex, rowIndex, columnIndex, defVal); -} +public: + virtual int GetSheetCount() override + { + try + { + return (int)m_workbook.sheet_count(); + } + catch (const std::exception& ex) + { + SetLastError(ex.what()); + return 0; + } + } -IKXIAO_API bool SetCellULLIntValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, unsigned long long int int_value) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->SetCellULLIntValue(sheetIndex, rowIndex, columnIndex, int_value); -} + virtual WorkSheet* OpenSheetByIndex(int sheetIndex) override + { + try + { + xlnt::worksheet sheet = m_workbook.sheet_by_index(sheetIndex); + WorkSheetImp* imp = new WorkSheetImp(sheet); + return imp; + } + catch (const std::exception& ex) + { + SetLastError(ex.what()); + return NULL; + } + } -IKXIAO_API unsigned long long int GetCellULLIntValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, unsigned long long int defVal) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->GetCellULLIntValue(sheetIndex, rowIndex, columnIndex, defVal); -} + virtual WorkSheet* OpenSheetByTitle(const char* sheetTitle) override + { + try + { + xlnt::worksheet sheet = m_workbook.sheet_by_title(sheetTitle); + WorkSheetImp* imp = new WorkSheetImp(sheet); + return imp; + } + catch (const std::exception& ex) + { + SetLastError(ex.what()); + return NULL; + } + } -IKXIAO_API bool SetCellDoubleValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, double float_value) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->SetCellDoubleValue(sheetIndex, rowIndex, columnIndex, float_value); -} + virtual bool SetCurrentSheet(WorkSheet* sheet) override + { + try + { + WorkSheetImp* imp = (WorkSheetImp*)sheet; + size_t idx = m_workbook.index(imp->raw()); + m_workbook.active_sheet(idx); + return true; + } + catch (const std::exception& ex) + { + SetLastError(ex.what()); + return false; + } + } -IKXIAO_API double GetCellDoubleValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, double defVal) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->GetCellDoubleValue(sheetIndex, rowIndex, columnIndex, defVal); -} + virtual WorkSheet* OpenCurrentSheet() override + { + try + { + xlnt::worksheet sheet = m_workbook.active_sheet(); + WorkSheetImp* imp = new WorkSheetImp(sheet); + return imp; + } + catch (const std::exception& ex) + { + SetLastError(ex.what()); + return NULL; + } + } -IKXIAO_API bool SetCellDateValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int year_, int month_, int day_) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->SetCellDateValue(sheetIndex, rowIndex, columnIndex, year_, month_, day_); -} + virtual WorkSheet* CreateSheet(int atIndex) override + { + try + { + xlnt::worksheet sheet; + if (atIndex < 0) + sheet = m_workbook.create_sheet(); + else + { + if (atIndex >= m_workbook.sheet_count()) + return NULL; + sheet = m_workbook.create_sheet(atIndex); + } + WorkSheetImp* imp = new WorkSheetImp(sheet); + return imp; + } + catch (const std::exception& ex) + { + SetLastError(ex.what()); + return NULL; + } + } -IKXIAO_API bool GetCellDateValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int& year_, int& month_, int& day_) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->GetCellDateValue(sheetIndex, rowIndex, columnIndex, year_, month_, day_); -} + virtual WorkSheet* CloneSheet(WorkSheet* srcSheet, int atIndex) override + { + try + { + WorkSheetImp* imp = (WorkSheetImp*)srcSheet; -IKXIAO_API bool SetCellDatetimeValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int year_, int month_, int day_, int hour_, int minute_, int second_, int microsecond_) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->SetCellDatetimeValue(sheetIndex, rowIndex, columnIndex, year_, month_, day_, hour_, minute_, second_, microsecond_); -} + if (atIndex < 0) + { + xlnt::worksheet sheet = m_workbook.copy_sheet(imp->raw()); + WorkSheetImp* newSheet = new WorkSheetImp(sheet); + return newSheet; + } + else + { + if (atIndex >= m_workbook.sheet_count()) + return NULL; + xlnt::worksheet sheet = m_workbook.copy_sheet(imp->raw(), atIndex); + WorkSheetImp* newSheet = new WorkSheetImp(sheet); + return newSheet; + } + } + catch (const std::exception& ex) + { + SetLastError(ex.what()); + return NULL; + } + } -IKXIAO_API bool GetCellDatetimeValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int& year_, int& month_, int& day_, int& hour_, int& minute_, int& second_, int& microsecond_) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->GetCellDatetimeValue(sheetIndex, rowIndex, columnIndex, year_, month_, day_, hour_, minute_, second_, microsecond_); -} + virtual bool RemoveSheet(WorkSheet* sheet) override + { + try + { + WorkSheetImp* imp = (WorkSheetImp*)sheet; + m_workbook.remove_sheet(imp->raw()); + return true; + } + catch (const std::exception& ex) + { + SetLastError(ex.what()); + return false; + } + } -IKXIAO_API bool SetCellTimeValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int hour_, int minute_, int second_, int microsecond_) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->SetCellTimeValue(sheetIndex, rowIndex, columnIndex, hour_, minute_, second_, microsecond_); -} + virtual bool Save(const char* filepath) override + { + try + { + m_workbook.save(xlnt::path(filepath)); + return true; + } + catch (const std::exception& ex) + { + SetLastError(ex.what()); + return false; + } + } -IKXIAO_API bool GetCellTimeValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int& hour_, int& minute_, int& second_, int& microsecond_) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->GetCellTimeValue(sheetIndex, rowIndex, columnIndex, hour_, minute_, second_, microsecond_); -} + virtual void CloseSheet(WorkSheet* sheet) override + { + if (!sheet) + return; + WorkSheetImp* imp = (WorkSheetImp*)sheet; + delete imp; + } -IKXIAO_API bool SetCellTimeDeltaValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int days_, int hours_, int minutes_, int seconds_, int microseconds_) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->SetCellTimeDeltaValue(sheetIndex, rowIndex, columnIndex, days_, hours_, minutes_, seconds_, microseconds_); -} + virtual void FreeString(char* buff) override + { + freeStringBuffer(buff); + } -IKXIAO_API bool GetCellTimeDeltaValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int days_, int& hours_, int& minutes_, int& seconds_, int& microseconds_) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->GetCellTimeDeltaValue(sheetIndex, rowIndex, columnIndex, days_, hours_, minutes_, seconds_, microseconds_); -} +public: + bool Open(const char* xlsxFilepath, const char* password) + { + std::string sPassword; + if (password && password[0] != '\0') + { + sPassword = password; + } -IKXIAO_API bool SetCellFormula(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, const char* formula) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->SetCellFormula(sheetIndex, rowIndex, columnIndex, formula); -} + try + { + //if the file path exist,load the file to workbook + if (IsPathExist(xlsxFilepath)) + { + if (sPassword.empty()) + m_workbook.load(xlnt::path(xlsxFilepath)); + else + m_workbook.load(xlnt::path(xlsxFilepath), sPassword); + } + } + catch (const std::exception& ex) + { + std::string error = ex.what(); + return false; + } -IKXIAO_API bool CopyCell(IK_WORKBOOK workbook, int sheetIndex, size_t fromRowIndex, size_t fromColumnIndex, size_t toRowIndex, size_t toColumnIndex) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->CopyCell(sheetIndex, fromRowIndex, fromColumnIndex, toRowIndex, toColumnIndex); -} + return true; + } -IKXIAO_API bool SaveExcel(IK_WORKBOOK workbook, const char* filepath, const char* password) -{ - iKXiaoImp* imp = (iKXiaoImp*)workbook; - return imp->Save(filepath, password); -} + xlnt::workbook& raw() + { + return m_workbook; + } + +private: + xlnt::workbook m_workbook; +}; -IKXIAO_API void FreeString(IK_WORKBOOK workbook, char* buff) +IKXIAO_API WorkBook* OpenExcel(const char* xlsxFilepath, const char* password) { - iKXiaoImp* imp = (iKXiaoImp*)workbook; - imp->freeStringBuffer(buff); + WorkBookImp* wb = new WorkBookImp(); + if (!wb->Open(xlsxFilepath, password)) + { + delete wb; + return NULL; + } + return wb; } -IKXIAO_API void CloseExcel(IK_WORKBOOK workbook) +IKXIAO_API void CloseExcel(WorkBook* workbook) { - iKXiaoImp* imp = (iKXiaoImp*)workbook; + if (!workbook) + return; + WorkBookImp* imp = (WorkBookImp*)workbook; delete imp; } diff --git a/iKXiao/iKXiao.h b/iKXiao/iKXiao.h index ae0481d..08bba5a 100644 --- a/iKXiao/iKXiao.h +++ b/iKXiao/iKXiao.h @@ -11,74 +11,105 @@ #define IKXIAO_API extern "C" __declspec(dllimport) #endif -typedef void* IK_WORKBOOK; -//typedef void* IK_WORKSHEET; -#define IDX_SHEET_CUR -1 -#define IDX_SHEET_LAST -2 -enum CellType +class Cell { - /// no value - empty_value, - /// value is TRUE or FALSE - boolean_value, - /// value is an ISO 8601 formatted date - date_value, - /// value is a known error code such as \#VALUE! - error_value, - /// value is a string stored in the cell - inline_string_value, - /// value is a number - number_value, - /// value is a string shared with other cells to save space - shared_string_value, - /// value is the string result of a formula - formula_string_value +public: + enum CellType + { + /// no value + empty_value, + /// value is TRUE or FALSE + boolean_value, + /// value is an ISO 8601 formatted date + date_value, + /// value is a known error code such as \#VALUE! + error_value, + /// value is a string stored in the cell + inline_string_value, + /// value is a number + number_value, + /// value is a string shared with other cells to save space + shared_string_value, + /// value is the string result of a formula + formula_string_value + }; + +public: + virtual CellType GetValueType() = 0; + virtual char* GetStringValue(const char* defVal = "") = 0; + virtual bool SetStringValue(const char* strVal) = 0; + virtual bool SetNullValue() = 0; + virtual bool SetBoolValue(bool boolean_value) = 0; + virtual bool GetBoolValue(bool defVal = false) = 0; + virtual bool SetIntValue(int int_value) = 0; + virtual int GetIntValue(int defVal = 0) = 0; + virtual bool SetUIntValue(unsigned int int_value) = 0; + virtual unsigned int GetUIntValue(unsigned int defVal = 0) = 0; + virtual bool SetLLIntValue(long long int int_value) = 0; + virtual long long int GetLLIntValue(long long int defVal = 0) = 0; + virtual bool SetULLIntValue(unsigned long long int int_value) = 0; + virtual unsigned long long int GetULLIntValue(unsigned long long int defVal = 0) = 0; + virtual bool SetDoubleValue(double float_value) = 0; + virtual double GetDoubleValue(double defVal = 0.0) = 0; + virtual bool SeDateValue(int year_, int month_, int day_) = 0; + virtual bool GetDateValue(int& year_, int& month_, int& day_) = 0; + virtual bool SetDatetimeValue(int year_, int month_, int day_, + int hour_ = 0, int minute_ = 0, int second_ = 0, int microsecond_ = 0) = 0; + virtual bool GetDatetimeValue(int& year_, int& month_, int& day_, + int& hour_, int& minute_, int& second_, int& microsecond_) = 0; + virtual bool SetTimeValue(int hour_ = 0, int minute_ = 0, int second_ = 0, int microsecond_ = 0) = 0; + virtual bool GetTimeValue(int& hour_, int& minute_, int& second_, int& microsecond_) = 0; + virtual bool SetTimeDeltaValue(int days_, int hours_, int minutes_, int seconds_, int microseconds_) = 0; + virtual bool GetTimeDeltaValue(int days_, int& hours_, int& minutes_, int& seconds_, int& microseconds_) = 0; + virtual bool SetFormula(const char* formula) = 0; + virtual bool CopyFrom(Cell* otherCell) = 0; + + virtual void FreeString(char* buff) = 0; +}; + +class WorkSheet +{ +public: + virtual char* GetSheetTitle() = 0; + virtual bool SetSheetTitle(const char* title) = 0; + virtual size_t GetRowCount() = 0; + virtual size_t GetColumnCount() = 0; + virtual size_t GetNotEmptyRowStart() = 0; + virtual size_t GetNotEmptyRowEnd() = 0; + virtual size_t GetNotEmptyColumnStart() = 0; + virtual size_t GetNotEmptyColumnEnd() = 0; + //»ñµÃÐÐÊý¾Ý£¬Êý¾Ý¸ñʽΪ"ÁÐ1ÄÚÈÝ\0ÁÐ2ÄÚÈÝ\0ÁÐ3ÄÚÈÝ\0" + virtual char* GetRowStringArray(size_t rowIndex, size_t* columnCount) = 0; + + virtual Cell* OpenCell(size_t rowIdx, int columnIdx) = 0; + virtual Cell* OpenCell(const char* refName) = 0; + virtual void CloseCell(Cell* cell) = 0; + + virtual void FreeString(char* buff) = 0; +}; + +class WorkBook +{ +public: + virtual int GetSheetCount() = 0; + virtual WorkSheet* OpenSheetByIndex(int sheetIndex) = 0; + virtual WorkSheet* OpenSheetByTitle(const char* sheetTitle) = 0; + virtual bool SetCurrentSheet(WorkSheet* sheet) = 0; + virtual WorkSheet* OpenCurrentSheet() = 0; + virtual WorkSheet* CreateSheet(int atIndex = -1) = 0; + virtual WorkSheet* CloneSheet(WorkSheet* srcSheet, int atIndex = -1) = 0; + virtual bool RemoveSheet(WorkSheet* sheet) = 0; + virtual bool Save(const char* filepath) = 0; + + virtual void CloseSheet(WorkSheet* sheet) = 0; + + virtual void FreeString(char* buff) = 0; }; -IKXIAO_API IK_WORKBOOK OpenExcel(const char* xlsxFilepath, const char* password); -IKXIAO_API int GetSheetCount(IK_WORKBOOK workbook); -IKXIAO_API int GetSheetIndexByTitle(IK_WORKBOOK workbook, const char* sheetTitle); -IKXIAO_API char* GetSheetTitle(IK_WORKBOOK workbook, int sheetIndex); -IKXIAO_API bool SetCurrentSheet(IK_WORKBOOK workbook, int sheetIndex); -IKXIAO_API int CreateSheet(IK_WORKBOOK workbook, int atIndex = -1); -IKXIAO_API int CopySheet(IK_WORKBOOK workbook, int srcIndex, int atIndex = -1); -IKXIAO_API bool RemoveSheet(IK_WORKBOOK workbook, int sheetIndex); -IKXIAO_API bool SetSheetTitle(IK_WORKBOOK workbook, int sheetIndex, const char* title); -IKXIAO_API size_t GetRowCount(IK_WORKBOOK workbook, int sheetIndex); -//»ñµÃÐÐÊý¾Ý£¬Êý¾Ý¸ñʽΪ"ÁÐ1ÄÚÈÝ\0ÁÐ2ÄÚÈÝ\0ÁÐ3ÄÚÈÝ\0" -IKXIAO_API char* GetRowStringArray(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t* columnCount); -IKXIAO_API CellType GetCellType(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex); -IKXIAO_API char* GetCellStringValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex); -IKXIAO_API char* GetCellStringValueByRefName(IK_WORKBOOK workbook, int sheetIndex, const char* refName); -IKXIAO_API bool SetCellStringValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, const char* strVal); -IKXIAO_API bool SetCellNullValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex); -IKXIAO_API bool SetCellBoolValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, bool boolean_value); -IKXIAO_API bool GetCellBoolValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, bool defVal = false); -IKXIAO_API bool SetCellIntValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int int_value); -IKXIAO_API int GetCellIntValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int defVal = 0); -IKXIAO_API bool SetCellUIntValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, unsigned int int_value); -IKXIAO_API unsigned int GetCellUIntValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, unsigned int defVal = 0); -IKXIAO_API bool SetCellLLIntValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, long long int int_value); -IKXIAO_API long long int GetCellLLIntValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, long long int defVal = 0); -IKXIAO_API bool SetCellULLIntValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, unsigned long long int int_value); -IKXIAO_API unsigned long long int GetCellULLIntValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, unsigned long long int defVal = 0); -IKXIAO_API bool SetCellDoubleValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, double float_value); -IKXIAO_API double GetCellDoubleValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, double defVal = 0.0); -IKXIAO_API bool SetCellDateValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int year_, int month_, int day_); -IKXIAO_API bool GetCellDateValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int& year_, int& month_, int& day_); -IKXIAO_API bool SetCellDatetimeValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int year_, int month_, int day_, int hour_ = 0, int minute_ = 0, int second_ = 0, int microsecond_ = 0); -IKXIAO_API bool GetCellDatetimeValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int& year_, int& month_, int& day_, int& hour_, int& minute_, int& second_, int& microsecond_); -IKXIAO_API bool SetCellTimeValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int hour_ = 0, int minute_ = 0, int second_ = 0, int microsecond_ = 0); -IKXIAO_API bool GetCellTimeValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int& hour_, int& minute_, int& second_, int& microsecond_); -IKXIAO_API bool SetCellTimeDeltaValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int days_, int hours_, int minutes_, int seconds_, int microseconds_); -IKXIAO_API bool GetCellTimeDeltaValue(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, int days_, int& hours_, int& minutes_, int& seconds_, int& microseconds_); -IKXIAO_API bool SetCellFormula(IK_WORKBOOK workbook, int sheetIndex, size_t rowIndex, size_t columnIndex, const char* formula); -IKXIAO_API bool CopyCell(IK_WORKBOOK workbook, int sheetIndex, size_t fromRowIndex, size_t fromColumnIndex, size_t toRowIndex, size_t toColumnIndex); -IKXIAO_API bool SaveExcel(IK_WORKBOOK workbook, const char* filepath, const char* password); -IKXIAO_API void FreeString(IK_WORKBOOK workbook, char* buff); -IKXIAO_API void CloseExcel(IK_WORKBOOK workbook); +IKXIAO_API WorkBook* OpenExcel(const char* xlsxFilepath, const char* password); +IKXIAO_API void CloseExcel(WorkBook* workbook); class iKXiao { @@ -96,89 +127,11 @@ class iKXiao return; SET_PROC(hDll, OpenExcel); - SET_PROC(hDll, GetSheetCount); - SET_PROC(hDll, GetSheetIndexByTitle); - SET_PROC(hDll, GetSheetTitle); - SET_PROC(hDll, SetCurrentSheet); - SET_PROC(hDll, CreateSheet); - SET_PROC(hDll, CopySheet); - SET_PROC(hDll, RemoveSheet); - SET_PROC(hDll, SetSheetTitle); - SET_PROC(hDll, GetRowCount); - SET_PROC(hDll, GetRowStringArray); - SET_PROC(hDll, GetCellType); - SET_PROC(hDll, GetCellStringValue); - SET_PROC(hDll, GetCellStringValueByRefName); - SET_PROC(hDll, SetCellStringValue); - SET_PROC(hDll, SetCellNullValue); - SET_PROC(hDll, SetCellBoolValue); - SET_PROC(hDll, GetCellBoolValue); - SET_PROC(hDll, SetCellIntValue); - SET_PROC(hDll, GetCellIntValue); - SET_PROC(hDll, SetCellUIntValue); - SET_PROC(hDll, GetCellUIntValue); - SET_PROC(hDll, SetCellLLIntValue); - SET_PROC(hDll, GetCellLLIntValue); - SET_PROC(hDll, SetCellULLIntValue); - SET_PROC(hDll, GetCellULLIntValue); - SET_PROC(hDll, SetCellDoubleValue); - SET_PROC(hDll, GetCellDoubleValue); - SET_PROC(hDll, SetCellDateValue); - SET_PROC(hDll, GetCellDateValue); - SET_PROC(hDll, SetCellDatetimeValue); - SET_PROC(hDll, GetCellDatetimeValue); - SET_PROC(hDll, SetCellTimeValue); - SET_PROC(hDll, GetCellTimeValue); - SET_PROC(hDll, SetCellTimeDeltaValue); - SET_PROC(hDll, GetCellTimeDeltaValue); - SET_PROC(hDll, SetCellFormula); - SET_PROC(hDll, CopyCell); - SET_PROC(hDll, SaveExcel); - SET_PROC(hDll, FreeString); SET_PROC(hDll, CloseExcel); } DEF_PROC(OpenExcel); - DEF_PROC(GetSheetCount); - DEF_PROC(GetSheetIndexByTitle); - DEF_PROC(GetSheetTitle); - DEF_PROC(SetCurrentSheet); - DEF_PROC(CreateSheet); - DEF_PROC(CopySheet); - DEF_PROC(RemoveSheet); - DEF_PROC(SetSheetTitle); - DEF_PROC(GetRowCount); - DEF_PROC(GetRowStringArray); - DEF_PROC(GetCellType); - DEF_PROC(GetCellStringValue); - DEF_PROC(GetCellStringValueByRefName); - DEF_PROC(SetCellStringValue); - DEF_PROC(SetCellNullValue); - DEF_PROC(SetCellBoolValue); - DEF_PROC(GetCellBoolValue); - DEF_PROC(SetCellIntValue); - DEF_PROC(GetCellIntValue); - DEF_PROC(SetCellUIntValue); - DEF_PROC(GetCellUIntValue); - DEF_PROC(SetCellLLIntValue); - DEF_PROC(GetCellLLIntValue); - DEF_PROC(SetCellULLIntValue); - DEF_PROC(GetCellULLIntValue); - DEF_PROC(SetCellDoubleValue); - DEF_PROC(GetCellDoubleValue); - DEF_PROC(SetCellDateValue); - DEF_PROC(GetCellDateValue); - DEF_PROC(SetCellDatetimeValue); - DEF_PROC(GetCellDatetimeValue); - DEF_PROC(SetCellTimeValue); - DEF_PROC(GetCellTimeValue); - DEF_PROC(SetCellTimeDeltaValue); - DEF_PROC(GetCellTimeDeltaValue); - DEF_PROC(SetCellFormula); - DEF_PROC(CopyCell); - DEF_PROC(SaveExcel); - DEF_PROC(FreeString); DEF_PROC(CloseExcel); diff --git a/iKXiao/iKXiao.vcxproj b/iKXiao/iKXiao.vcxproj index de4a070..c84c5aa 100644 --- a/iKXiao/iKXiao.vcxproj +++ b/iKXiao/iKXiao.vcxproj @@ -70,6 +70,20 @@ + + tmp\$(Platform)\$(Configuration)\ + + + tmp\$(Platform)\$(Configuration)\ + + + tmp\$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + + + tmp\$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + Level3