app/ExcelUtil.cpp | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/ExcelUtil.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/GUITool.cpp | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/GUITool.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/appDlg.cpp | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/libxls.dll | 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/libxls.lib | 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/libxls/include/libxls/xlstypes.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/libxls/lib/libxls.dll | 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/libxls/lib/libxls.exp | 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/libxls/lib/libxls.lib | 补丁 | 查看 | 原始文档 | blame | 历史 |
app/ExcelUtil.cpp
@@ -96,40 +96,50 @@ wb.Dump(path); } void ExcelUtil::read(string path) std::list<ExcelGPCodeInfo> ExcelUtil::readGPCodes(string path) { xlsWorkBook* pWB = NULL; // 工作表 xlsWorkSheet* pWS = NULL; // 单元格 xlsCell* cell = NULL; int sheetIndex; int sheetIndex=0; int row, col; // 打开文件 pWB = xls_open(path.c_str(), "UTF-8"); pWB = xls_open(path.c_str(), "GBK"); if (!pWB) { throw string("Open File Error!"); } // 解析xls文件,这个不要忘了 xls_parseWorkBook(pWB); fprintf(stderr, "Sheet count:%d\n", pWB->sheets.count); pWS = xls_getWorkSheet(pWB, 0); // 解析工作表 xls_parseWorkSheet(pWS); fprintf(stderr, "Sheet %d name: %s\n", sheetIndex, (char*)pWB->sheets.sheet[sheetIndex].name); fprintf(stderr, "Sheet Data:\n"); // 单元格 xlsCell* cell = NULL; // 每行 for (row = 0; row < pWS->rows.lastrow; ++row) { cell = xls_cell(pWS, row, 1); std::list<ExcelGPCodeInfo> codes; for (row = 0; row <= pWS->rows.lastrow; ++row) { ExcelGPCodeInfo info; cell = xls_cell(pWS, row, 0); if (cell && cell->str) { fprintf(stderr, "%s", (char*)cell->str); info.zyltgb = std::string((char*)cell->str); } cell = xls_cell(pWS, row, 1); if (cell && cell->str) { fprintf(stderr, " %s\n", (char*)cell->str); info.code = std::string((char*)cell->str); } codes.push_back(info); } return codes; } app/ExcelUtil.h
@@ -3,12 +3,19 @@ #include <afxstr.h> #include <xls.h> struct ExcelGPCodeInfo { string zyltgb; string code; }; class ExcelUtil { public: static void save(list<TradeData> data, string path); static void read(string path); static std::list<ExcelGPCodeInfo> readGPCodes(string path); }; app/GUITool.cpp
@@ -49,6 +49,27 @@ return 0; } CString GUITool::selectExcel() { TCHAR szBuffer[MAX_PATH] = { 0 }; OPENFILENAME ofn = { 0 }; ofn.lStructSize = sizeof(ofn); ofn.lpstrFilter = _T("All\0*.xls");//要选择的文件后缀 ofn.nFilterIndex = 1; ofn.lpstrFile = szBuffer;//存放文件的缓冲区 ofn.nMaxFile = sizeof(szBuffer) / sizeof(*szBuffer); ofn.nFilterIndex = 0; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; BOOL bSel = GetOpenFileName(&ofn); if (bSel) { return szBuffer; } return 0; } std::list<CString> GUITool::selectMulImages() { std::list<CString> paths; TCHAR szBuffer[MAX_PATH] = { 0 }; app/GUITool.h
@@ -9,6 +9,8 @@ static CString selectImage(); static CString selectExcel(); static std::list<CString> selectMulImages(); }; app/appDlg.cpp
@@ -1329,11 +1329,41 @@ // Excel上传股票代码 void CappDlg::OnBnClickedButtonUploadExcelCode() { CString cpath = GUITool::selectImage(); CString cpath = GUITool::selectExcel(); std:string path = Tool::cstring2String(cpath); if (path.length() > 0) { ExcelUtil::read(path); std::list<IndustryData> fresult; list<ExcelGPCodeInfo> codesList = ExcelUtil::readGPCodes(path); list<ExcelGPCodeInfo>::iterator ele; for (ele = codesList.begin();ele != codesList.end();++ele) { ExcelGPCodeInfo info= *ele; IndustryData finfo; if (info.code.length()>0) { finfo.code = info.code.replace(0, 2, ""); if (info.zyltgb.find("亿",0) > 0) { finfo.zyltMoneyUnit = MONEY_UNIT_Y; string zyltgb = info.zyltgb; finfo.zyltMoney = zyltgb.substr(0, zyltgb.length()-2); } else if (info.zyltgb.find("万",0) > 0) { finfo.zyltMoneyUnit = MONEY_UNIT_W; string zyltgb = info.zyltgb; finfo.zyltMoney = zyltgb.substr(0, zyltgb.length() - 2); } else { finfo.zyltMoneyUnit = MONEY_UNIT_NO; finfo.zyltMoney = info.zyltgb; } fresult.push_back(finfo); } } codesDataDlog::codeData = fresult; codesDataDlog::upload = TRUE; codesDataDlog dlg; dlg.DoModal(); } app/libxls.dllBinary files differ
app/libxls.libBinary files differ
app/libxls/include/libxls/xlstypes.h
@@ -44,6 +44,7 @@ typedef uint32_t DWORD_UA; #else #ifdef _WIN32 typedef __declspec(align(1)) uint16_t WORD_UA; typedef __declspec(align(1)) uint32_t DWORD_UA; @@ -51,6 +52,5 @@ typedef uint16_t WORD_UA __attribute__((aligned(1))); // 2 bytes typedef uint32_t DWORD_UA __attribute__((aligned(1))); // 4 bytes #endif #endif #endif app/libxls/lib/libxls.dllBinary files differ
app/libxls/lib/libxls.expBinary files differ
app/libxls/lib/libxls.libBinary files differ