From 1a16b19acb23a4f28bafd01f3ed80fb225a96c3e Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 30 九月 2022 18:04:12 +0800 Subject: [PATCH] 'bug修复' --- ConsoleApplication/OpenCLExcuter.cpp | 6 ConsoleApplication/CurrentPriceCapture.cpp | 84 ++ app/libxls/include/libxls/xlstool.h | 52 + app/app.aps | 0 app/libxls/include/libxls/xlstypes.h | 56 + app/libxls/lib/xlstool.o | 0 ConsoleApplication/L2DataCapture.h | 2 app/libxls/lib/libxls.def | 76 ++ app/libxls/lib/libxls.lib | 0 ConsoleApplication/THSActionUtil.h | 4 app/appDlg.h | 4 app/libxls.dll | 0 ConsoleApplication/main.cpp | 8 app/ExcelUtil.cpp | 39 + app/libxls/lib/libxls.exp | 0 ConsoleApplication/CurrentPriceCapture.h | 2 app/libxls/lib/endian.o | 0 app/libxls/lib/libxlsreader.la | 41 + app/libxls/lib/ole.o | 0 ConsoleApplication/LimitUpCapture.cpp | 26 ConsoleApplication/Win32Util.h | 3 ConsoleApplication/L2DataCapture.cpp | 14 ConsoleApplication/Win32Util.cpp | 6 app/libxls/include/libxls/brdb.h | 58 ++ app/app.vcxproj | 6 app/user.txt | 2 app/libxls/include/libxls/brdb.c.h | 208 +++++++ app/libxls/lib/libxls.dll | 0 app/resource.h | 3 app/JsonUtil.h | 6 app/libxls.lib | 0 app/libxls/bin/xls2csv.exe | 0 app/libxls/include/libxls/xlsstruct.h | 478 ++++++++++++++++ app/libxls/include/xls.h | 76 ++ app/libxls/lib/xls.o | 0 app/app.vcxproj.user | 6 app/libxls/lib/libxlsreader.a | 0 app/appDlg.cpp | 55 + ConsoleApplication/CaptureUtil.cpp | 2 ConsoleApplication/kernel.cl | 116 +++ app/libxls/include/libxls/ole.h | 173 +++++ app/app.rc | 0 ConsoleApplication/THSActionUtil.cpp | 74 ++ app/ExcelUtil.h | 2 ConsoleApplication/THSGPDataCapture.cpp | 1 45 files changed, 1,613 insertions(+), 76 deletions(-) diff --git a/ConsoleApplication/CaptureUtil.cpp b/ConsoleApplication/CaptureUtil.cpp index 8bf3dc2..1b28294 100644 --- a/ConsoleApplication/CaptureUtil.cpp +++ b/ConsoleApplication/CaptureUtil.cpp @@ -120,6 +120,6 @@ cv::Mat CaptureUtil::capture(HWND hwnd) { clock_t starttime = clock(); cv::Mat cap = _wss::screen_shot_by_window(hwnd); - std::cout << "截图耗时: threadid-" << std::this_thread::get_id() << " 耗时:" << clock() - starttime << endl; + //std::cout << "截图耗时: threadid-" << std::this_thread::get_id() << " 耗时:" << clock() - starttime << endl; return cap; } \ No newline at end of file diff --git a/ConsoleApplication/CurrentPriceCapture.cpp b/ConsoleApplication/CurrentPriceCapture.cpp index 108e673..1f8c3ee 100644 --- a/ConsoleApplication/CurrentPriceCapture.cpp +++ b/ConsoleApplication/CurrentPriceCapture.cpp @@ -32,7 +32,7 @@ if (kill) break; if (tradeTimeCapture) { - if (!GPUtil::isPreTradeTime()) { + if (!GPUtil::isTradeTime()) { Sleep(100); continue; } @@ -72,7 +72,12 @@ thread rt(&(CurrentPriceCapture::_run)); rt.detach(); inited = true; - refreshHWND(); + try { + refreshHWND(); + } + catch (string st) { + + } } void CurrentPriceCapture::reCreateRunning() { @@ -124,7 +129,8 @@ list<int*> rowData = THSActionUtil::splitPlateRowArea(grayImg); //每行的元素个数 - int ele_count_per_line = 2; + int ele_count_per_line = 3; + int length_per_num = 6; int* splitResult = (int*)malloc(sizeof(int) * 4 * 4 * rowData.size()); int* rowIndex = (int*)malloc(sizeof(int) * 4 * rowData.size()); int count = 0; @@ -141,9 +147,9 @@ count++; } - int line_number_count = ele_count_per_line * 6; + int line_number_count = ele_count_per_line * length_per_num; - openCLExcuter->splitPlateContentRowData(grayImg.data, grayImg.cols, grayImg.rows, rowIndex, rowData.size(), ele_count_per_line,1,2,splitResult); + openCLExcuter->splitPlateContentRowData(grayImg.data, grayImg.cols, grayImg.rows, rowIndex, rowData.size(), ele_count_per_line,1,3,splitResult); /* *测试 @@ -183,10 +189,9 @@ UcharDataInfo typesData = UcharDataInfo(); - unsigned char types[] = { NUM_TYPE_CODE, NUM_TYPE_PRICE }; - typesData.length = 2; + unsigned char types[] = { NUM_TYPE_MONEY, NUM_TYPE_CODE, NUM_TYPE_PRICE }; + typesData.length = 3; typesData.data = types; - int length_per_num = 6; openCLExcuter->splitPlateNum(grayImg, IntDataInfo({ splitResult,(int)(ele_count_per_line * rowData.size()) }), UcharDataInfo({ totalNumberData, -1 }), typesData, zeroData, _NUMBER_GP_CODE_WIDTH, _NUMBER_GP_CODE_HEIGHT, ele_count_per_line, length_per_num); @@ -200,24 +205,34 @@ list<CurrentPriceData> dataList; for (int i = 0;i < rowData.size();i++) { CurrentPriceData currentData = CurrentPriceData(); - string code = ""; - for (int j = 0;j < 6;j++) + + string volumn = ""; + for (int j = 0;j < length_per_num;j++) { - code.append(to_string(numberResult[i][j])); + if (j == 4) { + volumn.append("."); + } + volumn.append(to_string(numberResult[i][length_per_num * 0 + j])); + } + + string code = ""; + for (int j = 0;j < length_per_num;j++) + { + code.append(to_string(numberResult[i][length_per_num * 1 + j])); } string price = ""; - for (int j = 0;j < 6;j++) + for (int j = 0;j < length_per_num;j++) { if (j == 4) { price.append("."); } - price.append(to_string(numberResult[i][6 * 1 + j])); + price.append(to_string(numberResult[i][length_per_num * 2 + j])); } currentData.index = i; currentData.code = code; - + currentData.volumn = volumn; currentData.price = price; if ( currentData.price != "0000.00") { dataList.push_back(currentData); @@ -226,12 +241,53 @@ } free(numberResult); int* unitData = (int*)malloc(sizeof(int) * 4 * dataList.size()); + //获取量的单位 + int index = 0; + for (list<CurrentPriceData>::iterator ele = dataList.begin();ele != dataList.end();ele++) { + unitData[index * 4 + 0] = splitResult[(*ele).index * 4 * ele_count_per_line + 4 * 0 + 0]; + unitData[index * 4 + 1] = splitResult[(*ele).index * 4 * ele_count_per_line + 4 * 0 + 1]; + unitData[index * 4 + 2] = splitResult[(*ele).index * 4 * ele_count_per_line + 4 * 0 + 2]; + unitData[index * 4 + 3] = splitResult[(*ele).index * 4 * ele_count_per_line + 4 * 0 + 3]; + index++; + } + int* unitResult = (int*)malloc(sizeof(int) * dataList.size()); + openCLExcuter->recognitionPlateMoneyUnit(grayImg.data, grayImg.cols, grayImg.rows, unitData, 1, dataList.size(), unitResult); + index = 0; + for (list<CurrentPriceData>::iterator ele = dataList.begin();ele != dataList.end();ele++) { + switch (unitResult[index]) + { + case 0: + (*ele).volumnUnit = MONEY_UNIT_Y; + break; + case 1: + (*ele).volumnUnit = MONEY_UNIT_W; + break; + case 2: + (*ele).volumnUnit = MONEY_UNIT_NO; + (*ele).volumn = to_string((int)round( stof((*ele).volumn) * 100)); + default: + break; + } + //cout<< (*ele).code<<" "<< (*ele).price <<" "<< (*ele).volumn; + //if ((*ele).volumnUnit == MONEY_UNIT_Y) { + // cout <<"亿"<<endl; + //}else if ((*ele).volumnUnit == MONEY_UNIT_W) { + // cout << "万" << endl; + //} + //else { + // cout << "" << endl; + //} + + index++; + } + free(rowIndex); free(splitResult); free(zeroData); free(templateNums); free(unitData); + free(unitResult); free(imgData); grayImg.release(); diff --git a/ConsoleApplication/CurrentPriceCapture.h b/ConsoleApplication/CurrentPriceCapture.h index 3dbcd5b..89162de 100644 --- a/ConsoleApplication/CurrentPriceCapture.h +++ b/ConsoleApplication/CurrentPriceCapture.h @@ -10,6 +10,8 @@ { string code; string price; + string volumn; + MoneyUnit volumnUnit; //辅助功能 int index; }; diff --git a/ConsoleApplication/L2DataCapture.cpp b/ConsoleApplication/L2DataCapture.cpp index 50ee635..ad033d5 100644 --- a/ConsoleApplication/L2DataCapture.cpp +++ b/ConsoleApplication/L2DataCapture.cpp @@ -48,9 +48,11 @@ string code = gpCodes[index]; try { clock_t start = clock(); - list<TradeData> resultList = captureLevel2TradeData(CaptureUtil::capture(index, CAPTURE_TYPE_L2), index); - data_callback(index, code, resultList, context); - cout << "时间消耗:" << clock() - start << endl; + cv::Mat mat = CaptureUtil::capture(index, CAPTURE_TYPE_L2); + list<TradeData> resultList = captureLevel2TradeData(mat, index); + long processTime = clock() - start; + data_callback(index, code, start , processTime, resultList, context); + cout << "时间消耗:" << processTime << endl; } catch (...) { @@ -80,11 +82,9 @@ } void L2DataCapture::setGPCode(int index, string code) { - int length = sizeof(gpCodes) / sizeof(gpCodes[0]); - if (length <= index) { + if (THS_FRAME_COUNT <= index) { return; } - gpCodes[index] = code; } @@ -198,7 +198,7 @@ list<TradeData> resultList= captureLevel2TradeData(openCLExcuter[identify], oimg, identify); - std::cout << "-------L2行情识别结束任务: threadid-" << std::this_thread::get_id() << " 序号:" << identify << " 耗时:" << clock() - starttime <<" 数据量:"<< resultList.size() << endl; + std::cout << "-------L2行情识别结束任务: threadid-" << std::this_thread::get_id() << " 序号:" << identify << " CODE:"<< gpCodes[identify] << " 耗时:" << clock() - starttime <<" 数据量:"<< resultList.size() << endl; return resultList; } diff --git a/ConsoleApplication/L2DataCapture.h b/ConsoleApplication/L2DataCapture.h index 6a19291..1d5a457 100644 --- a/ConsoleApplication/L2DataCapture.h +++ b/ConsoleApplication/L2DataCapture.h @@ -8,7 +8,7 @@ #include "BaseCapture.h" #define THS_FRAME_COUNT 8 -typedef void (*CallbackFun)(int index, string code, list<TradeData> dataList, void* contex); +typedef void (*CallbackFun)(int index, string code,long captureTime,long processTime, list<TradeData> dataList, void* contex); typedef void (*CallbackFun_Trade_Queue)(int index, string code, list<int> numList, void* contex); diff --git a/ConsoleApplication/LimitUpCapture.cpp b/ConsoleApplication/LimitUpCapture.cpp index ac34154..b218564 100644 --- a/ConsoleApplication/LimitUpCapture.cpp +++ b/ConsoleApplication/LimitUpCapture.cpp @@ -246,8 +246,8 @@ path.append(to_string(i)).append("_").append(to_string(j)).append(".jpg"); //cv::imwrite(path, cv::Mat(grayImg, cv::Rect(sx, sy, ex - sx + 1, ey - sy + 1))); } - int sx = splitResult[(ele_count_per_line * i + 0) * 4 + 0]; - int ex = splitResult[(ele_count_per_line * i + 0) * 4 + 2]; + int sx = splitResult[(ele_count_per_line * i + 1) * 4 + 0]; + int ex = splitResult[(ele_count_per_line * i + 1) * 4 + 2]; if (ex - sx < 40) { //噪点数据 excudeIndexs.insert(i); @@ -338,6 +338,7 @@ } percent.append(to_string(numberResult[i][num_length_per_ele * 4 + j])); } + /* if (percent == "0000.00") { int sx = splitResult[(ele_count_per_line * i + 4) * 4 + 0]; int sy = splitResult[(ele_count_per_line * i + 4) * 4 + 1]; @@ -347,6 +348,7 @@ path.append(to_string(i)).append("_").append(".jpg"); cv::imwrite(path, cv::Mat(grayImg, cv::Rect(sx, sy, ex - sx + 1, ey - sy + 1))); } + */ limitUpData.index = i; limitUpData.code = code; @@ -449,15 +451,21 @@ PostMessage(win, WM_MOUSEWHEEL, 0, MAKEWORD(x, y)); Sleep(200); cv::Mat oimg = CaptureUtil::capture(win); - list<LimitUpData> codes = captureLimitUpCodes(oimg); - for (list<LimitUpData>::iterator ele = codes.begin();ele != codes.end();ele++) { - string code = (*ele).code; - if (codesSet.count(code) == 0) { - codesSet.insert(code); - flist.push_back(*ele); + try { + list<LimitUpData> codes = captureLimitUpCodes(oimg); + for (list<LimitUpData>::iterator ele = codes.begin();ele != codes.end();ele++) { + string code = (*ele).code; + if (codesSet.count(code) == 0) { + codesSet.insert(code); + flist.push_back(*ele); + } } + codes.clear(); } - codes.clear(); + catch (string e) { + cout << e << endl; + } + Sleep(50); } } diff --git a/ConsoleApplication/OpenCLExcuter.cpp b/ConsoleApplication/OpenCLExcuter.cpp index 7d556ee..395bdbd 100644 --- a/ConsoleApplication/OpenCLExcuter.cpp +++ b/ConsoleApplication/OpenCLExcuter.cpp @@ -384,6 +384,12 @@ error = clEnqueueReadBuffer(queue, memObject4, CL_TRUE, 0, resultSize * sizeof(unsigned char), result.data, 0, NULL, NULL); if (error != CL_SUCCESS) { + clReleaseKernel(kernel); + clReleaseMemObject(memObject1); + clReleaseMemObject(memObject2); + clReleaseMemObject(memObject3); + clReleaseMemObject(memObject4); + clReleaseMemObject(memObject5); throw string("Error reading result buffer!\n"); } diff --git a/ConsoleApplication/THSActionUtil.cpp b/ConsoleApplication/THSActionUtil.cpp index 26da8ec..7de914c 100644 --- a/ConsoleApplication/THSActionUtil.cpp +++ b/ConsoleApplication/THSActionUtil.cpp @@ -541,6 +541,7 @@ std::list<int*> dataItemList; for (int i = start_row;i < end_row;i++) { + //TODO 100 bool empty = ImgDivider::isRowEmpty(img, i, start_col, start_col + 50, 1, _IMG_BINARY_THRESHOLD) && ImgDivider::isRowEmpty(img, i, start_col + 50, start_col + 150, 2, _IMG_BINARY_THRESHOLD) && ImgDivider::isRowEmpty(img, i, start_col + (end_col - start_col) / 2 - 40, start_col + (end_col - start_col) / 2 + 40, 1, _IMG_BINARY_THRESHOLD); if (empty) { if (emptyStartRow < 0) { @@ -667,7 +668,7 @@ } } - if (contentStartRow < 0|| contentStartRow>rows-100) { + if (contentStartRow < 0 || contentStartRow>rows - 100) { throw string("起始行分隔出错(18)"); } @@ -1039,7 +1040,7 @@ } contentEndRow = contentStartRow + 50; - + //分隔列 list<int*> dataColIndexs; int startf = -1; @@ -1286,11 +1287,11 @@ } Sleep(200); - addDialog = FindWindowExA(addDialog, NULL,"AfxWnd100s","CEFBrowser" ); + addDialog = FindWindowExA(addDialog, NULL, "AfxWnd100s", "CEFBrowser"); addDialog = FindWindowExA(addDialog, NULL, "CefBrowserWindow", NULL); addDialog = FindWindowExA(addDialog, NULL, "Chrome_WidgetWin_0", NULL); addDialog = FindWindowExA(addDialog, NULL, "Chrome_RenderWidgetHostHWND", NULL); - cout << "添加股票弹框:"<< addDialog << endl; + cout << "添加股票弹框:" << addDialog << endl; Win32Util::focus(addDialog); @@ -1422,7 +1423,7 @@ lastBar = bar; } bar = FindWindowEx(hwnd, bar, TEXT("msctls_statusbar32"), NULL); - if (count > 10|| bar<=0) { + if (count > 10 || bar <= 0) { bar = 0; break; } @@ -1447,7 +1448,7 @@ bool THSActionUtil::thsIsDead() { - cv::Mat oldMat= getTHSTimeCapture(); + cv::Mat oldMat = getTHSTimeCapture(); Sleep(1200); cv::Mat newMat = getTHSTimeCapture(); @@ -1457,6 +1458,67 @@ return FALSE; } +void THSActionUtil::updateMainSite() +{ + //获取主页 + HWND main = getMainWin(); + if (main <= 0) { + throw string("同花顺主页未打开"); + } + Win32Util::showWindow(main); + //获取toolbar + HWND win = NULL; + do { + win = FindWindowExA(main, win, "AfxControlBar100s", ""); + if (win <= 0) { + break; + } + + RECT rect; + GetWindowRect(win, &rect); + if (rect.bottom - rect.top >= 40 && rect.bottom - rect.top <= 60) { + break; + } + } while (true); + + if (win <= 0) { + throw string("测速按钮未找到"); + } + + win = FindWindowExA(win, NULL, "#32770", ""); + if (win <= 0) { + throw string("测速按钮未找到"); + } + + HWND btn = GetDlgItem(win, 0x00007A17); + if (btn <= 0) { + throw string("测速按钮未找到"); + } + + //点击按钮 + Win32Util::visualClick(btn, MAKELONG(3,3)); + for (int i = 0;i < 10;i++) { + list<HWND> _list = Win32Util::searchWindow("选择最优行情主站"); + if (_list.size() > 0) { + HWND win = *(_list.begin()); + HWND loginBtn = 0; + for (int j = 0;j < 10;j++) + { + loginBtn = FindWindowExA(win, NULL, "Button", "登 录"); + if (loginBtn > 0) { + //点击登录按钮 + Win32Util::visualClick(loginBtn, MAKELONG(2, 2)); + break; + } + Sleep(200); + } + } + Sleep(400); + } + + + +} void THSActionUtil::clearPlateCodes(HWND hwnd) { HWND content = FindWindowExA(hwnd, NULL, "AfxFrameOrView100s", NULL); diff --git a/ConsoleApplication/THSActionUtil.h b/ConsoleApplication/THSActionUtil.h index 8f99f0b..a4b4903 100644 --- a/ConsoleApplication/THSActionUtil.h +++ b/ConsoleApplication/THSActionUtil.h @@ -17,6 +17,7 @@ enum MoneyUnit { MONEY_UNIT_Y, MONEY_UNIT_W, + MONEY_UNIT_NO, }; struct GPCodeArea { @@ -108,5 +109,8 @@ //同花顺是否卡死 static bool thsIsDead(); + //更新行情主站 + static void updateMainSite(); + }; diff --git a/ConsoleApplication/THSGPDataCapture.cpp b/ConsoleApplication/THSGPDataCapture.cpp index 362d80d..76ed13b 100644 --- a/ConsoleApplication/THSGPDataCapture.cpp +++ b/ConsoleApplication/THSGPDataCapture.cpp @@ -32,7 +32,6 @@ list<list<GPDataStruct>> THSGPDataCapture::captureGPData(cv::Mat grayImg, SplitType types[], int length_per_num, int startColumn, int endColumn) { - list<int*> rowData = THSActionUtil::splitPlateRowArea(grayImg); int count = 0; int* rowIndex = (int*)malloc(sizeof(int) * 4 * rowData.size()); diff --git a/ConsoleApplication/Win32Util.cpp b/ConsoleApplication/Win32Util.cpp index bde47cf..879eb43 100644 --- a/ConsoleApplication/Win32Util.cpp +++ b/ConsoleApplication/Win32Util.cpp @@ -246,5 +246,11 @@ GetWindowRect(hwnd, rect); } +void Win32Util::visualClick(HWND hwnd, LPARAM pos) +{ + PostMessage(hwnd, WM_LBUTTONDOWN, 0x00000001, pos); + PostMessage(hwnd, WM_LBUTTONUP, 0x00000000, pos); +} + diff --git a/ConsoleApplication/Win32Util.h b/ConsoleApplication/Win32Util.h index 0c19745..ceca2fb 100644 --- a/ConsoleApplication/Win32Util.h +++ b/ConsoleApplication/Win32Util.h @@ -55,5 +55,8 @@ //获取位置 static void getWindowRect(HWND hwnd,RECT *rect); + + //虚拟点击 + static void visualClick(HWND hwnd, LPARAM pos); }; diff --git a/ConsoleApplication/kernel.cl b/ConsoleApplication/kernel.cl index 8f523d0..893640c 100644 --- a/ConsoleApplication/kernel.cl +++ b/ConsoleApplication/kernel.cl @@ -116,6 +116,8 @@ //只能识别4种数字 unsigned char type = types[index % ele_count_per_line]; //printf("ele_count_line:%d\n", ele_count_line); + //是否只有一位小数 + bool one_point_num = false; //时间 if (type == 0) { //时间 @@ -220,7 +222,9 @@ //查找单位前的空格 int num_end = -1; int i; - for (i = endx - 11;i >= startx;i--) { + //获取是否有单位 + int last_empty_index = -1; + for (i = endx;i >= startx;i--) { bool empty = 1; for (int y = starty;y < endy;y++) { if (get_binary_value(img_in[get_one_level_position(width, i, y)]) > 0) { @@ -229,8 +233,29 @@ } } if (empty) { - num_end = i - 1; + last_empty_index = i; break; + } + } + bool hasUnit = false; + if (endx - last_empty_index > num_width) { + hasUnit = true; + } + + //带有单位 + if (hasUnit) { + for (i = endx - 11;i >= startx;i--) { + bool empty = 1; + for (int y = starty;y < endy;y++) { + if (get_binary_value(img_in[get_one_level_position(width, i, y)]) > 0) { + empty = 0; + break; + } + } + if (empty) { + num_end = i - 1; + break; + } } } @@ -327,10 +352,19 @@ if (m_s == -1 || m_e == -1) { //printf("没找到小数点:%d", index); - nps[0] = -1; - nps[1] = -1; - nps[2] = -1; - nps[3] = -1; + if (hasUnit) + { + nps[0] = -1; + nps[1] = -1; + nps[2] = -1; + nps[3] = -1; + } + else { + nps[0] = startx; + nps[1] = starty; + nps[2] = endx; + nps[3] = endy; + } nps[4] = -1; nps[5] = -1; @@ -350,6 +384,9 @@ nps[5] = starty; nps[6] = num_end; nps[7] = endy; + if (nps[6] - nps[4] + 1 <= num_width) { + one_point_num = true; + } } nps[8] = -1; @@ -454,7 +491,7 @@ } //百分比 else if (type == 5) { - + //百分比数字起始位置 int percent_start = -1; int emptyIndex = -1; @@ -469,18 +506,19 @@ } if (empty) { emptyIndex = i; - }else if (emptyIndex > 0) { + } + else if (emptyIndex > 0) { percent_start = i; break; } } - + //百分比数字的结束位置 int percent_end = -1; emptyIndex = -1; - + for (i = endx;i >= startx;i--) { bool empty = 1; for (int y = starty;y < endy;y++) { @@ -491,13 +529,14 @@ } if (empty) { emptyIndex = i; - }else if (emptyIndex > 0) { + } + else if (emptyIndex > 0) { percent_end = i; break; } } - + if (percent_start > -1) { startx = percent_start; @@ -507,7 +546,7 @@ endx = percent_end; } - + //按照价格的形式做识别 int m_s = -1, m_e = -1; uchar temp[8]; @@ -546,7 +585,7 @@ } if (m_s == -1 || m_e == -1) { - + nps[0] = -1; nps[1] = -1; nps[2] = -1; @@ -636,7 +675,7 @@ } } - int zeroCount = length_per_num - numCount; + int zeroCount = length_per_num - numCount - (one_point_num?1:0); //最大为20位数 int fresult[20 * 2]; for (i = 0;i < zeroCount;i++) { @@ -647,6 +686,11 @@ for (i = 0;i < numCount;i++) { fresult[(i + zeroCount) * 2] = numberCols[i * 2]; fresult[(i + zeroCount) * 2 + 1] = numberCols[i * 2 + 1]; + } + //一位小数需要在末尾填充0 + if (type == 1 && one_point_num) { + fresult[(numCount + zeroCount) * 2] = -1; + fresult[(numCount + zeroCount) * 2 + 1] = -1; } //开始填充数据 @@ -776,7 +820,10 @@ //只能识别4种数字 unsigned char type = types[index % ele_count_per_line]; //printf("ele_count_line:%d\n", ele_count_line); + //是否只有一位小数 + bool one_point_num = false; //时间 + if (type == 0) { //时间 int s = cols / 2; @@ -998,6 +1045,10 @@ nps[5] = starty; nps[6] = num_end; nps[7] = endy; + if (nps[6] - nps[4] <= num_width) { + //只有一个数字 + one_point_num = true; + } } @@ -1160,7 +1211,7 @@ } } - int zeroCount = length_per_num - numCount; + int zeroCount = length_per_num - numCount - (one_point_num?1:0); //最大为20位数 int fresult[20 * 2]; for (i = 0;i < zeroCount;i++) { @@ -1171,6 +1222,12 @@ for (i = 0;i < numCount;i++) { fresult[(i + zeroCount) * 2] = numberCols[i * 2]; fresult[(i + zeroCount) * 2 + 1] = numberCols[i * 2 + 1]; + } + + //TODO 如果是金额,且后面只有1位小数的,需要在末尾填充0 + if (type == 1&& one_point_num) { + fresult[(numCount + zeroCount) * 2] = -1; + fresult[(numCount + zeroCount) * 2 + 1] = -1; } //开始填充数据 @@ -2204,6 +2261,33 @@ int unit_start = -1; int i; + + //查询是否有单位 + //获取是否有单位 + int last_empty_index = -1; + for (i = endx;i >= startx;i--) { + bool empty = 1; + for (int y = starty;y < endy;y++) { + if (get_binary_value(imgs[get_one_level_position(width, i, y)]) > 0) { + empty = 0; + break; + } + } + if (empty) { + last_empty_index = i; + break; + } + } + bool hasUnit = false; + if (endx - last_empty_index > 6) { + hasUnit = true; + } + else { + //没有单位 + result[index] = 2; + return; + } + for (i = endx - 11;i >= startx;i--) { bool empty = 1; for (int y = starty;y < endy;y++) { diff --git a/ConsoleApplication/main.cpp b/ConsoleApplication/main.cpp index 7bf1d8a..781bf72 100644 --- a/ConsoleApplication/main.cpp +++ b/ConsoleApplication/main.cpp @@ -147,13 +147,7 @@ cout << "寮�濮嬬▼搴�" << endl; ImgUtil::init(); - bool dead= THSActionUtil::thsIsDead(); - - - //cv::imshow("test",cv::Mat(cv::imread("C:\\Users\\Administrator\\Desktop\\ocr\\limit_up\\浼佷笟寰俊鎴浘_16624495173041.png"), cv::Rect(619, 123, 34, 10))); - - cv::Mat img = ImgUtil::grayImage(cv::imread("C:\\Users\\Administrator\\Desktop\\ocr\\鏃堕棿.png")); - cv::imwrite("C:\\Users\\Administrator\\Desktop\\ocr\\鏃堕棿_gray.png", cv::Mat( img,cv::Rect(img.cols-60,0,60,19))); + THSActionUtil::updateMainSite(); cv::waitKey(0); diff --git a/app/ExcelUtil.cpp b/app/ExcelUtil.cpp index 511cf1a..8567f2e 100644 --- a/app/ExcelUtil.cpp +++ b/app/ExcelUtil.cpp @@ -2,6 +2,8 @@ #include "ExcelUtil.h" #include "json/json.h" #include "xlslib.h" +#include <libxls/xlsstruct.h> +using namespace xls; using namespace xlslib_core; void ExcelUtil::save(list<TradeData> data, string path) { @@ -94,3 +96,40 @@ wb.Dump(path); } +void ExcelUtil::read(string path) +{ + + xlsWorkBook* pWB = NULL; + + // 工作表 + xlsWorkSheet* pWS = NULL; + // 单元格 + xlsCell* cell = NULL; + + int sheetIndex; + int row, col; + + // 打开文件 + pWB = xls_open(path.c_str(), "UTF-8"); + 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"); + // 每行 + for (row = 0; row < pWS->rows.lastrow; ++row) { + cell = xls_cell(pWS, row, 1); + if (cell && cell->str) { + fprintf(stderr, "%s", (char*)cell->str); + } + } +} + diff --git a/app/ExcelUtil.h b/app/ExcelUtil.h index 64e60ba..593d85b 100644 --- a/app/ExcelUtil.h +++ b/app/ExcelUtil.h @@ -1,12 +1,14 @@ #pragma once #include <L2DataCapture.h> #include <afxstr.h> +#include <xls.h> class ExcelUtil { public: static void save(list<TradeData> data, string path); + static void read(string path); }; diff --git a/app/JsonUtil.h b/app/JsonUtil.h index fb5d0d1..6445cd0 100644 --- a/app/JsonUtil.h +++ b/app/JsonUtil.h @@ -57,10 +57,12 @@ return jsonStr; } - static std::string loadL2Data(int clientID, int channel, string code, std::list<TradeData> dataList) { + static std::string loadL2Data(int clientID, int channel, string code, long captureTime, long processTime, std::list<TradeData> dataList) { Json::Value data; data["channel"] = channel; data["code"] = code; + data["captureTime"] = captureTime; + data["processTime"] = processTime; data["data"] = toJson(dataList); Json::Value root; root["type"] = 0; @@ -212,6 +214,8 @@ Json::Value item; item["code"] = (*ele).code; item["price"] = (*ele).price; + item["volumn"] = (*ele).volumn; + item["volumnUnit"] = (*ele).volumnUnit; data[index++] = item; } root["data"] = data; diff --git a/app/app.aps b/app/app.aps index 4562268..47b7e3e 100644 --- a/app/app.aps +++ b/app/app.aps Binary files differ diff --git a/app/app.rc b/app/app.rc index 5ae7b66..3b420e7 100644 --- a/app/app.rc +++ b/app/app.rc Binary files differ diff --git a/app/app.vcxproj b/app/app.vcxproj index 7967ee3..e8f4336 100644 --- a/app/app.vcxproj +++ b/app/app.vcxproj @@ -96,12 +96,12 @@ <SDLCheck>false</SDLCheck> <PreprocessorDefinitions>_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> - <AdditionalIncludeDirectories>D:\workspace\CPlusTest\ConsoleApplication\xls_lib;D:\opencv\build\include\opencv2;D:\opencv\build\include;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include;D:\workspace\CPlusTest\ConsoleApplication\ConsoleApplication\;D:\workspace\CPlusTest\ConsoleApplication\app\lib_json\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>D:\workspace\CPlusTest\ConsoleApplication\app\libxls\include;D:\workspace\CPlusTest\ConsoleApplication\xls_lib;D:\opencv\build\include\opencv2;D:\opencv\build\include;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include;D:\workspace\CPlusTest\ConsoleApplication\ConsoleApplication\;D:\workspace\CPlusTest\ConsoleApplication\app\lib_json\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ClCompile> <Link> <SubSystem>Windows</SubSystem> - <AdditionalLibraryDirectories>D:\workspace\CPlusTest\ConsoleApplication\xlslib;D:\opencv\build\x64\vc15\lib;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> - <AdditionalDependencies>opencv_world455d.lib;OpenCL.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalLibraryDirectories>D:\opencv\build\x64\vc15\lib;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + <AdditionalDependencies>opencv_world455d.lib;OpenCL.lib;ws2_32.lib;libxls.lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> <Midl> <MkTypLibCompatible>false</MkTypLibCompatible> diff --git a/app/app.vcxproj.user b/app/app.vcxproj.user index b6cc81f..6029798 100644 --- a/app/app.vcxproj.user +++ b/app/app.vcxproj.user @@ -5,9 +5,9 @@ </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> - <RemoteDebuggerCommand>\\192.168.3.242\FXDMounter\Debug\DataCapture.exe</RemoteDebuggerCommand> - <RemoteDebuggerWorkingDirectory>\\192.168.3.242\FXDMounter\</RemoteDebuggerWorkingDirectory> - <RemoteDebuggerServerName>192.168.3.242</RemoteDebuggerServerName> + <RemoteDebuggerCommand>\\192.168.3.241\FXDMounter\Debug\DataCapture.exe</RemoteDebuggerCommand> + <RemoteDebuggerWorkingDirectory>\\192.168.3.241\FXDMounter\</RemoteDebuggerWorkingDirectory> + <RemoteDebuggerServerName>192.168.3.241</RemoteDebuggerServerName> <RemoteDebuggerConnection>RemoteWithoutAuthentication</RemoteDebuggerConnection> </PropertyGroup> </Project> \ No newline at end of file diff --git a/app/appDlg.cpp b/app/appDlg.cpp index 6d1b406..1a55095 100644 --- a/app/appDlg.cpp +++ b/app/appDlg.cpp @@ -30,6 +30,7 @@ #include "loginDlg.h" #include <psapi.h> #pragma comment(lib,"psapi.lib") +#include "ExcelUtil.h" // 鐢ㄤ簬搴旂敤绋嬪簭鈥滃叧浜庘�濊彍鍗曢」鐨� CAboutDlg 瀵硅瘽妗� @@ -130,6 +131,7 @@ DDX_Control(pDX, IDC_CHECK_TRADE_TIME_TRADE_SUCCESS, tradeSuccessTimeCheck); DDX_Control(pDX, IDC_CHECK_TRADE_TIME_DELEGATE, delegateTimeCheck); DDX_Control(pDX, IDC_CHECK_TRADE_TIME_LIMIT_UP, limitUpTimeCheck); + DDX_Control(pDX, IDC_BUTTON_UPLOAD_EXCEL_CODE, uploadExcelGPBtn); } BEGIN_MESSAGE_MAP(CappDlg, CDialogEx) @@ -160,6 +162,7 @@ ON_BN_CLICKED(IDC_CHECK_TRADE_TIME_TRADE_SUCCESS, &CappDlg::OnBnClickedCheckTradeTimeTradeSuccess) ON_BN_CLICKED(IDC_CHECK_TRADE_TIME_DELEGATE, &CappDlg::OnBnClickedCheckTradeTimeDelegate) ON_BN_CLICKED(IDC_CHECK_PRICE_TIME_LIMIT, &CappDlg::OnBnClickedCheckPriceTimeLimit) + ON_BN_CLICKED(IDC_BUTTON_UPLOAD_EXCEL_CODE, &CappDlg::OnBnClickedButtonUploadExcelCode) END_MESSAGE_MAP() @@ -203,9 +206,17 @@ L2DataCapture::setTradeTimeCapture(true); limitUpTimeCheck.SetCheck(TRUE); + LimitUpCapture::setTradeTimeCapture(limitUpTimeCheck.GetCheck()); + tradeSuccessTimeCheck.SetCheck(TRUE); + TradeListCapture::setTradeTimeCapture_success(tradeSuccessTimeCheck.GetCheck()); + delegateTimeCheck.SetCheck(TRUE); + TradeListCapture::setTradeTimeCapture_delegate(delegateTimeCheck.GetCheck()); + priceTimeLimitCheck.SetCheck(TRUE); + CurrentPriceCapture::setTradeTimeCapture(priceTimeLimitCheck.GetCheck()); + @@ -273,9 +284,11 @@ if (authoritySet.count(AUTHORITY_UPLOAD_CODE) > 0) { uploadGPBtn.EnableWindow(TRUE); + uploadExcelGPBtn.EnableWindow(TRUE); } else { uploadGPBtn.EnableWindow(FALSE); + uploadExcelGPBtn.EnableWindow(FALSE); } @@ -352,14 +365,14 @@ } -void CappDlg::OnL2DataCallback(int index, string code, list<TradeData> dataList, void* context) { +void CappDlg::OnL2DataCallback(int index, string code, long captureTime, long processTime, list<TradeData> dataList, void* context) { //杞负json CappDlg* app = (CappDlg*)context; //cout << "鍥炶皟:" << std::this_thread::get_id() << ":" << index << endl; CButton* btn = (CButton*)app->GetDlgItem(IDC_CHECK1); bool check = btn->GetCheck(); if (check) { - string data = JsonUtil::loadL2Data(app->clientNum, index, code, dataList); + string data = JsonUtil::loadL2Data(app->clientNum, index, code, captureTime, processTime, dataList); clock_t time_start = clock(); try { app->socketManager->sendMsg(index, data.c_str()); @@ -562,6 +575,8 @@ int key = (*ele).first; string value = (*ele).second; app->capture->setGPCode(key, value); + cout << "浠g爜浣嶏細" << key << " CODE:" << value; + //TODO 璁板綍鏃ュ織 } Sleep(500); } @@ -735,6 +750,14 @@ root["data"] = data; root["client"] = clientNum; return JsonUtil::toJsonStr(root); + } + else if (action == "updateTHSSite") { + try { + THSActionUtil::updateMainSite(); + } + catch (string st) { + throw st; + } } return ""; @@ -1259,7 +1282,12 @@ for (list<CString>::iterator ele = paths.begin();ele != paths.end();ele++) { CString path = *ele; std:string p = Tool::cstring2String(path); - cv::Mat grayImg = gpDataCapture->grayImgs(cv::imread(p)); + cv::Mat img = cv::imread(p); + //cv::Mat _img; + //cv::resize(img, _img, cv::Size(img.cols * 2 / 3, img.rows * 2 / 3)); + + cv::Mat grayImg = gpDataCapture->grayImgs(img); + SplitType types[] = { NUM_TYPE_MONEY, NUM_TYPE_CODE }; @@ -1297,6 +1325,22 @@ codesDataDlog dlg; dlg.DoModal(); } + +// Excel涓婁紶鑲$エ浠g爜 +void CappDlg::OnBnClickedButtonUploadExcelCode() +{ + CString cpath = GUITool::selectImage(); +std:string path = Tool::cstring2String(cpath); + if (path.length() > 0) + { + ExcelUtil::read(path); + } + + + +} + + //娑ㄥ仠涓婁紶 void CappDlg::OnBnClickedButton12() @@ -1495,7 +1539,7 @@ - string data = JsonUtil::loadL2Data(clientNum, 0, "002338", dataList); + string data = JsonUtil::loadL2Data(clientNum, 0, "002338",0,0, dataList); clock_t time_start = clock(); try { socketManager->sendMsg(index, data.c_str()); @@ -1717,3 +1761,6 @@ // 鐜颁环璇嗗埆鏃舵闄愬埗 CurrentPriceCapture::setTradeTimeCapture(priceTimeLimitCheck.GetCheck()); } + + + diff --git a/app/appDlg.h b/app/appDlg.h index f32c609..a9559e2 100644 --- a/app/appDlg.h +++ b/app/appDlg.h @@ -44,7 +44,7 @@ THSL2RepairTool *thsL2RepairTool; void OnDataCallback(int index, list<TradeData> dataList); - static void OnL2DataCallback(int index,string code, list<TradeData> dataList, void* context); + static void OnL2DataCallback(int index,string code, long captureTime, long processTime, list<TradeData> dataList, void* context); static void OnTradeQueueDataCallback(int index, string code, list<int> numList, void* context); static void OnLimitUpDataCallback(list<LimitUpData> dataList, void* context); static void OnTradeSuccessDataCallback(list<TradeSuccessData> dataList, void* context); @@ -148,4 +148,6 @@ afx_msg void OnBnClickedCheckTradeTimeTradeSuccess(); afx_msg void OnBnClickedCheckTradeTimeDelegate(); afx_msg void OnBnClickedCheckPriceTimeLimit(); + CButton uploadExcelGPBtn; + afx_msg void OnBnClickedButtonUploadExcelCode(); }; diff --git a/app/libxls.dll b/app/libxls.dll new file mode 100644 index 0000000..87ebf62 --- /dev/null +++ b/app/libxls.dll Binary files differ diff --git a/app/libxls.lib b/app/libxls.lib new file mode 100644 index 0000000..cbfb568 --- /dev/null +++ b/app/libxls.lib Binary files differ diff --git a/app/libxls/bin/xls2csv.exe b/app/libxls/bin/xls2csv.exe new file mode 100644 index 0000000..63fd85b --- /dev/null +++ b/app/libxls/bin/xls2csv.exe Binary files differ diff --git a/app/libxls/include/libxls/brdb.c.h b/app/libxls/include/libxls/brdb.c.h new file mode 100644 index 0000000..de0623c --- /dev/null +++ b/app/libxls/include/libxls/brdb.c.h @@ -0,0 +1,208 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * This file is part of libxls -- A multiplatform, C/C++ library + * for parsing Excel(TM) files. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY David Hoerl ''AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David Hoerl OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Copyright 2004 Komarov Valery + * Copyright 2006 Christophe Leitienne + * Copyright 2008-2012 David Hoerl + * + */ + +{ 0x00, "Unknown", ""}, +{ 0x06, "FORMULA", "Cell Formula" }, +{ 0x09, "BOF-BIFF2", "Beginning of File" }, +{ 0x0A, "EOF", "End of File" }, +{ 0x0C, "CALCCOUNT", "Iteration Count" }, +{ 0x0D, "CALCMODE", "Calculation Mode" }, +{ 0x0E, "PRECISION", "Precision" }, +{ 0x0F, "REFMODE", "Reference Mode" }, +{ 0x10, "DELTA", "Iteration Increment" }, +{ 0x11, "ITERATION", "Iteration Mode" }, +{ 0x12, "PROTECT", "Protection Flag" }, +{ 0x13, "PASSWORD", "Protection Password" }, +{ 0x14, "HEADER", "Print Header on Each Page" }, +{ 0x15, "FOOTER", "Print Footer on Each Page" }, +{ 0x16, "EXTERNCOUNT", "Number of External References" }, +{ 0x17, "EXTERNSHEET", "External Reference" }, +{ 0x19, "?WINDOWPROTECT", " (biffview guessed)" }, +{ 0x1A, "VERTICALPAGEBREAKS", "Explicit Column Page Breaks" }, +{ 0x1B, "HORIZONTALPAGEBREAKS", "Explicit Row Page Breaks" }, +{ 0x1C, "NOTE", "Comment Associated with a Cell" }, +{ 0x1D, "SELECTION", "Current Selection" }, +{ 0x22, "DATEMODE", "1904 Date System" }, +{ 0x26, "LEFTMARGIN", "Left Margin Measurement" }, +{ 0x27, "RIGHTMARGIN", "Right Margin Measurement" }, +{ 0x28, "TOPMARGIN", "Top Margin Measurement" }, +{ 0x29, "BOTTOMMARGIN", "Bottom Margin Measurement" }, +{ 0x2A, "PRINTHEADERS", "Print Row/Column Labels" }, +{ 0x2B, "PRINTGRIDLINES", "Print Gridlines Flag" }, +{ 0x2F, "FILEPASS", "File Is Password-Protected" }, +{ 0x31, "FONT", "Font Description" }, +{ 0x3C, "CONTINUE", "Continues Long Records" }, +{ 0x3D, "WINDOW1", "Window Information" }, +{ 0x40, "BACKUP", "Save Backup Version of the File" }, +{ 0x41, "PANE", "Number of Panes and Their Position" }, +{ 0x42, "CODEPAGE", "Default Code Page" }, +{ 0x4D, "PLS", "Environment-Specific Print Record" }, +{ 0x50, "DCON", "Data Consolidation Information" }, +{ 0x51, "DCONREF", "Data Consolidation References" }, +{ 0x52, "DCONNAME", "Data Consolidation Named References" }, +{ 0x55, "DEFCOLWIDTH", "Default Width for Columns" }, +{ 0x59, "XCT", "CRN Record Count" }, +{ 0x5A, "CRN", "Nonresident Operands" }, +{ 0x5B, "FILESHARING", "File-Sharing Information" }, +{ 0x5C, "WRITEACCESS", "Write Access User Name" }, +{ 0x5D, "OBJ", "Describes a Graphic Object" }, +{ 0x5E, "UNCALCED", "Recalculation Status" }, +{ 0x5F, "SAVERECALC", "Recalculate Before Save" }, +{ 0x60, "TEMPLATE", "Workbook Is a Template" }, +{ 0x63, "OBJPROTECT", "Objects Are Protected" }, +{ 0x7D, "COLINFO", "Column Formatting Information" }, +{ 0x7F, "IMDATA", "Image Data" }, +{ 0x80, "GUTS", "Size of Row and Column Gutters" }, +{ 0x81, "WSBOOL", "Additional Workspace Information" }, +{ 0x82, "GRIDSET", "State Change of Gridlines Option" }, +{ 0x83, "HCENTER", "Center Between Horizontal Margins" }, +{ 0x84, "VCENTER", "Center Between Vertical Margins" }, +{ 0x85, "BOUNDSHEET", "Sheet Information" }, +{ 0x86, "WRITEPROT", "Workbook Is Write-Protected" }, +{ 0x87, "ADDIN", "Workbook Is an Add-in Macro" }, +{ 0x88, "EDG", "Edition Globals" }, +{ 0x89, "PUB", "Publisher" }, +{ 0x8C, "COUNTRY", "Default Country and WIN.INI Country" }, +{ 0x8D, "HIDEOBJ", "Object Display Options" }, +{ 0x90, "SORT", "Sorting Options" }, +{ 0x91, "SUB", "Subscriber" }, +{ 0x92, "PALETTE", "Color Palette Definition" }, +{ 0x94, "LHRECORD", ".WK? File Conversion Information" }, +{ 0x95, "LHNGRAPH", "Named Graph Information" }, +{ 0x96, "SOUND", "Sound Note" }, +{ 0x99, "STANDARDWIDTH", "Standard Column Width" }, +{ 0x98, "LPR", "Sheet Was Printed Using LINE.PRINT" }, +{ 0x9A, "FNGROUPNAME", "Function Group Name" }, +{ 0x9B, "FILTERMODE", "Sheet Contains Filtered List" }, +{ 0x9C, "FNGROUPCOUNT", "Built-in Function Group Count" }, +{ 0x9D, "AUTOFILTERINFO", "Drop-Down Arrow Count" }, +{ 0x9E, "AUTOFILTER", "AutoFilter Data" }, +{ 0xA0, "SCL", "Window Zoom Magnification" }, +{ 0xA1, "SETUP", "Page Setup" }, +{ 0xA9, "COORDLIST", "Polygon Object Vertex Coordinates" }, +{ 0xAB, "GCW", "Global Column-Width Flags" }, +{ 0xAE, "SCENMAN", "Scenario Output Data" }, +{ 0xAF, "SCENARIO", "Scenario Data" }, +{ 0xB0, "SXVIEW", "View Definition" }, +{ 0xB1, "SXVD", "View Fields" }, +{ 0xB2, "SXVI", "View Item" }, +{ 0xB4, "SXIVD", "Row/Column Field IDs" }, +{ 0xB5, "SXLI", "Line Item Array" }, +{ 0xB6, "SXPI", "Page Item" }, +{ 0xB8, "DOCROUTE", "Routing Slip Information" }, +{ 0xB9, "RECIPNAME", "Recipient Name" }, +{ 0xBC, "SHRFMLA", "Shared Formula" }, +{ 0xBD, "MULRK", "Multiple RK Cells" }, +{ 0xBE, "MULBLANK", "Multiple Blank Cells" }, +{ 0xC1, "MMS", "ADDMENU/DELMENU Record Group Count" }, +{ 0xC2, "ADDMENU", "Menu Addition" }, +{ 0xC3, "DELMENU", "Menu Deletion" }, +{ 0xC5, "SXDI", "Data Item" }, +{ 0xC6, "SXDB", "PivotTable Cache Data" }, +{ 0xCD, "SXSTRING", "String" }, +{ 0xD0, "SXTBL", "Multiple Consolidation Source Info" }, +{ 0xD1, "SXTBRGIITM", "Page Item Name Count" }, +{ 0xD2, "SXTBPG", "Page Item Indexes" }, +{ 0xD3, "OBPROJ", "Visual Basic Project" }, +{ 0xD5, "SXIDSTM", "Stream ID" }, +{ 0xD6, "RSTRING", "Cell with Character Formatting" }, +{ 0xD7, "DBCELL", "Stream Offsets" }, +{ 0xDA, "BOOKBOOL", "Workbook Option Flag" }, +{ 0xDC, "PARAMQRY-SXEXT", "Query Parameters-External Source Information" }, +{ 0xDD, "SCENPROTECT", "Scenario Protection" }, +{ 0xDE, "OLESIZE", "Size of OLE Object" }, +{ 0xDF, "UDDESC", "Description String for Chart Autoformat" }, +{ 0xE0, "XF", "Extended Format" }, +{ 0xE1, "INTERFACEHDR", "Beginning of User Interface Records" }, +{ 0xE2, "INTERFACEEND", "End of User Interface Records" }, +{ 0xE3, "SXVS", "View Source" }, +{ 0xE5, "CSPAN", "Cells span" }, +{ 0xEA, "TABIDCONF", "Sheet Tab ID of Conflict History" }, +{ 0xEB, "MSODRAWINGGROUP", "Microsoft Office Drawing Group" }, +{ 0xEC, "MSODRAWING", "Microsoft Office Drawing" }, +{ 0xED, "MSODRAWINGSELECTION", "Microsoft Office Drawing Selection" }, +{ 0xF0, "SXRULE", "PivotTable Rule Data" }, +{ 0xF1, "SXEX", "PivotTable View Extended Information" }, +{ 0xF2, "SXFILT", "PivotTable Rule Filter" }, +{ 0xF6, "SXNAME", "PivotTable Name" }, +{ 0xF7, "SXSELECT", "PivotTable Selection Information" }, +{ 0xF8, "SXPAIR", "PivotTable Name Pair" }, +{ 0xF9, "SXFMLA", "PivotTable Parsed Expression" }, +{ 0xFB, "SXFORMAT", "PivotTable Format Record" }, +{ 0xFC, "SST", "Shared String Table" }, +{ 0xFD, "LABELSST", "Cell Value, String Constant/SST" }, +{ 0xFF, "EXTSST", "Extended Shared String Table" }, +{ 0x100, "SXVDEX", "Extended PivotTable View Fields" }, +{ 0x103, "SXFORMULA", "PivotTable Formula Record" }, +{ 0x122, "SXDBEX", "PivotTable Cache Data" }, +{ 0x13D, "TABID", "Sheet Tab Index Array" }, +{ 0x160, "USESELFS", "Natural Language Formulas Flag" }, +{ 0x161, "DSF", "Double Stream File" }, +{ 0x162, "XL5MODIFY", "Flag for DSF" }, +{ 0x1A5, "FILESHARING2", "File-Sharing Information for Shared Lists" }, +{ 0x1A9, "USERBVIEW", "Workbook Custom View Settings" }, +{ 0x1AA, "USERSVIEWBEGIN", "Custom View Settings" }, +{ 0x1AB, "USERSVIEWEND", "End of Custom View Records" }, +{ 0x1AD, "QSI", "External Data Range" }, +{ 0x1AE, "SUPBOOK", "Supporting Workbook" }, +{ 0x1AF, "PROT4REV", "Shared Workbook Protection Flag" }, +{ 0x1B0, "CONDFMT", "Conditional Formatting Range Information" }, +{ 0x1B1, "CF", "Conditional Formatting Conditions" }, +{ 0x1B2, "DVAL", "Data Validation Information" }, +{ 0x1B5, "DCONBIN", "Data Consolidation Information" }, +{ 0x1B6, "TXO", "Text Object" }, +{ 0x1B7, "REFRESHALL", "Refresh Flag" }, +{ 0x1B8, "HLINK", "Hyperlink" }, +{ 0x1BB, "SXFDBTYPE", "SQL Datatype Identifier" }, +{ 0x1BC, "PROT4REVPASS", "Shared Workbook Protection Password" }, +{ 0x1BE, "DV", "Data Validation Criteria" }, +{ 0x200, "DIMENSIONS", "Cell Table Size" }, +{ 0x201, "BLANK", "Cell Value, Blank Cell" }, +{ 0x203, "NUMBER", "Cell Value, Floating-Point Number" }, +{ 0x204, "LABEL", "Cell Value, String Constant" }, +{ 0x205, "BOOLERR", "Cell Value, Boolean or Error" }, +{ 0x207, "STRING", "String Value of a Formula" }, +{ 0x208, "ROW", "Describes a Row" }, +{ 0x209, "BOF-BIFF3", "Beginning of File" }, +{ 0x20B, "INDEX", "Index Record" }, +{ 0x218, "NAME", "Defined Name" }, +{ 0x221, "ARRAY", "Array-Entered Formula" }, +{ 0x223, "EXTERNNAME", "Externally Referenced Name" }, +{ 0x225, "DEFAULTROWHEIGHT", "Default Row Height" }, +{ 0x236, "TABLE", "Data Table" }, +{ 0x23E, "WINDOW2", "Sheet Window Information" }, +{ 0x27E, "RK", "Cell Value, RK Number" }, +{ 0x293, "STYLE", "Style Information" }, +{ 0x409, "BOF-BIFF4", "Beginning of File" }, +{ 0x41E, "FORMAT", "Number Format" }, +{ 0x4BC, "?FORMULA-RELATED=?(BC=SHRFMLA))", "Formula related, always before there are 0x06 (FORMULA)" }, +{ 0x809, "BOF-BIFF5/7/8", "Beginning of File" }, +{ 0xFFF, "", "" }, diff --git a/app/libxls/include/libxls/brdb.h b/app/libxls/include/libxls/brdb.h new file mode 100644 index 0000000..86c1da6 --- /dev/null +++ b/app/libxls/include/libxls/brdb.h @@ -0,0 +1,58 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * This file is part of libxls -- A multiplatform, C/C++ library + * for parsing Excel(TM) files. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY David Hoerl ''AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David Hoerl OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Copyright 2004 Komarov Valery + * Copyright 2006 Christophe Leitienne + * Copyright 2008-2012 David Hoerl + * + */ + +struct str_brdb +{ + WORD opcode; + char * name; /* printable name */ + char * desc; /* printable description */ +}; +typedef struct str_brdb record_brdb; + +record_brdb brdb[] = + { +#include <libxls/brdb.c.h> + }; + +static int get_brbdnum(int id) +{ + + int i; + i=0; + do + { + if (brdb[i].opcode==id) + return i; + i++; + } + while (brdb[i].opcode!=0xFFF); + return 0; +} diff --git a/app/libxls/include/libxls/ole.h b/app/libxls/include/libxls/ole.h new file mode 100644 index 0000000..b7f39ef --- /dev/null +++ b/app/libxls/include/libxls/ole.h @@ -0,0 +1,173 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * This file is part of libxls -- A multiplatform, C/C++ library + * for parsing Excel(TM) files. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY David Hoerl ''AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David Hoerl OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Copyright 2004 Komarov Valery + * Copyright 2006 Christophe Leitienne + * Copyright 2013 Bob Colbert + * Copyright 2008-2013 David Hoerl + * + */ + +#ifndef OLE_INCLUDE +#define OLE_INCLUDE + +#include <stdio.h> // FILE * + +#include "libxls/xlstypes.h" + +#ifdef AIX +#pragma pack(1) +#else +#pragma pack(push, 1) +#endif + +typedef struct TIME_T +{ + DWORD LowDate; + DWORD HighDate; +} +TIME_T; + +typedef struct OLE2Header +{ + DWORD id[2]; //D0CF11E0 A1B11AE1 + DWORD clid[4]; + WORD verminor; //0x3e + WORD verdll; //0x03 + WORD byteorder; + WORD lsectorB; + WORD lssectorB; + + WORD reserved1; + DWORD reserved2; + DWORD reserved3; + + DWORD cfat; // count full sectors + DWORD dirstart; + + DWORD reserved4; + + DWORD sectorcutoff; // min size of a standard stream ; if less than this then it uses short-streams + DWORD sfatstart; // first short-sector or EOC + DWORD csfat; // count short sectors + DWORD difstart; // first sector master sector table or EOC + DWORD cdif; // total count + DWORD MSAT[109]; // First 109 MSAT +} +OLE2Header; + +#pragma pack(pop) + +//----------------------------------------------------------------------------------- +typedef struct st_olefiles +{ + long count; + struct st_olefiles_data + { + BYTE* name; + DWORD start; + DWORD size; + } + * file; +} +st_olefiles; + +typedef struct OLE2 +{ + FILE* file; + WORD lsector; + WORD lssector; + DWORD cfat; + DWORD dirstart; + + DWORD sectorcutoff; + DWORD sfatstart; + DWORD csfat; + DWORD difstart; + DWORD cdif; + DWORD* SecID; // regular sector data + DWORD* SSecID; // short sector data + BYTE* SSAT; // directory of short sectors + st_olefiles files; +} +OLE2; + +typedef struct OLE2Stream +{ + OLE2* ole; + DWORD start; + size_t pos; + size_t cfat; + size_t size; + size_t fatpos; + BYTE* buf; + DWORD bufsize; + BYTE eof; + BYTE sfat; // short +} +OLE2Stream; + +#ifdef AIX +#pragma pack(1) +#else +#pragma pack(push, 1) +#endif + +typedef struct PSS +{ + BYTE name[64]; + WORD bsize; + BYTE type; //STGTY +#define PS_EMPTY 00 +#define PS_USER_STORAGE 01 +#define PS_USER_STREAM 02 +#define PS_USER_ROOT 05 + BYTE flag; //COLOR +#define BLACK 1 + DWORD left; + DWORD right; + DWORD child; + WORD guid[8]; + DWORD userflags; + TIME_T time[2]; + DWORD sstart; + DWORD size; + DWORD proptype; +} +PSS; + +#pragma pack(pop) + +extern size_t ole2_read(void* buf,size_t size,size_t count,OLE2Stream* olest); +extern OLE2Stream* ole2_sopen(OLE2* ole,DWORD start, size_t size); +extern void ole2_seek(OLE2Stream* olest,DWORD ofs); +extern OLE2Stream* ole2_fopen(OLE2* ole,BYTE* file); +extern void ole2_fclose(OLE2Stream* ole2st); +extern OLE2* ole2_open(const BYTE *file); +extern void ole2_close(OLE2* ole2); +extern void ole2_bufread(OLE2Stream* olest); + + +#endif diff --git a/app/libxls/include/libxls/xlsstruct.h b/app/libxls/include/libxls/xlsstruct.h new file mode 100644 index 0000000..dc4128b --- /dev/null +++ b/app/libxls/include/libxls/xlsstruct.h @@ -0,0 +1,478 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * This file is part of libxls -- A multiplatform, C/C++ library + * for parsing Excel(TM) files. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY David Hoerl ''AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David Hoerl OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Copyright 2004 Komarov Valery + * Copyright 2006 Christophe Leitienne + * Copyright 2013 Bob Colbert + * Copyright 2008-2013 David Hoerl + * + */ + +#ifndef XLS_STRUCT_INC +#define XLS_STRUCT_INC + +#include "libxls/ole.h" + +#ifdef AIX +#pragma pack(1) +#else +#pragma pack(push, 1) +#endif + +typedef struct BOF +{ + WORD id; + WORD size; +} +BOF; + +typedef struct BIFF +{ + WORD ver; + WORD type; + WORD id_make; + WORD year; + DWORD flags; + DWORD min_ver; + BYTE buf[100]; +} +BIFF; + +typedef struct WIND1 +{ + WORD xWn; + WORD yWn; + WORD dxWn; + WORD dyWn; + WORD grbit; + WORD itabCur; + WORD itabFirst; + WORD ctabSel; + WORD wTabRatio; +} +WIND1; + +typedef struct BOUNDSHEET +{ + DWORD filepos; + BYTE type; + BYTE visible; + BYTE name[]; +} +BOUNDSHEET; + +typedef struct ROW +{ + WORD index; + WORD fcell; + WORD lcell; + WORD height; + WORD notused; + WORD notused2; //used only for BIFF3-4 + WORD flags; + WORD xf; +} +ROW; + +typedef struct COL +{ + WORD row; + WORD col; + WORD xf; +} +COL; + + +typedef struct FORMULA // BIFF8 +{ + WORD row; + WORD col; + WORD xf; + // next 8 bytes either a IEEE double, or encoded on a byte basis + BYTE resid; + BYTE resdata[5]; + WORD res; + WORD flags; + BYTE chn[4]; // BIFF8 + WORD len; + BYTE value[1]; //var +} +FORMULA; + +typedef struct FARRAY // BIFF8 +{ + WORD row1; + WORD row2; + BYTE col1; + BYTE col2; + WORD flags; + BYTE chn[4]; // BIFF8 + WORD len; + BYTE value[1]; //var +} +FARRAY; + +typedef struct RK +{ + WORD row; + WORD col; + WORD xf; + DWORD_UA value; +} +RK; + +typedef struct MULRK +{ + WORD row; + WORD col; + struct { + WORD xf; + DWORD_UA value; + } rk[]; + //WORD last_col; +} +MULRK; + +typedef struct MULBLANK +{ + WORD row; + WORD col; + WORD xf[]; + //WORD last_col; +} +MULBLANK; + +typedef struct BLANK +{ + WORD row; + WORD col; + WORD xf; +} +BLANK; + +typedef struct LABEL +{ + WORD row; + WORD col; + WORD xf; + BYTE value[1]; // var +} +LABEL; +typedef LABEL LABELSST; + +typedef struct SST +{ + DWORD num; + DWORD numofstr; + BYTE strings; +} +SST; + +typedef struct XF5 +{ + WORD font; + WORD format; + WORD type; + WORD align; + WORD color; + WORD fill; + WORD border; + WORD linestyle; +} +XF5; + +typedef struct XF8 +{ + WORD font; + WORD format; + WORD type; + BYTE align; + BYTE rotation; + BYTE ident; + BYTE usedattr; + DWORD linestyle; + DWORD linecolor; + WORD groundcolor; +} +XF8; + +typedef struct BR_NUMBER +{ + WORD row; + WORD col; + WORD xf; + double value; +} +BR_NUMBER; + +typedef struct COLINFO +{ + WORD first; + WORD last; + WORD width; + WORD xf; + WORD flags; + WORD notused; +} +COLINFO; + +typedef struct MERGEDCELLS +{ + WORD rowf; + WORD rowl; + WORD colf; + WORD coll; +} +MERGEDCELLS; + +typedef struct FONT +{ + WORD height; + WORD flag; + WORD color; + WORD bold; + WORD escapement; + BYTE underline; + BYTE family; + BYTE charset; + BYTE notused; + BYTE name; +} +FONT; + +typedef struct FORMAT +{ + WORD index; + BYTE value[0]; +} +FORMAT; + +#pragma pack(pop) + +//--------------------------------------------------------- + +typedef struct st_sheet +{ + DWORD count; // Count of sheets + struct st_sheet_data + { + DWORD filepos; + BYTE visibility; + BYTE type; + BYTE* name; + } + * sheet; +} +st_sheet; + +typedef struct st_font +{ + DWORD count; // Count of FONT's + struct st_font_data + { + WORD height; + WORD flag; + WORD color; + WORD bold; + WORD escapement; + BYTE underline; + BYTE family; + BYTE charset; + BYTE* name; + } + * font; +} +st_font; + +typedef struct st_format +{ + DWORD count; // Count of FORMAT's + struct st_format_data + { + WORD index; + BYTE *value; + } + * format; +} +st_format; + +typedef struct st_xf +{ + DWORD count; // Count of XF + // XF** xf; + struct st_xf_data + { + WORD font; + WORD format; + WORD type; + BYTE align; + BYTE rotation; + BYTE ident; + BYTE usedattr; + DWORD linestyle; + DWORD linecolor; + WORD groundcolor; + } + * xf; +} +st_xf; + + +typedef struct st_sst +{ + DWORD count; + DWORD lastid; + DWORD continued; + DWORD lastln; + DWORD lastrt; + DWORD lastsz; + struct str_sst_string + { + BYTE* str; + } + * string; +} +st_sst; + + +typedef struct st_cell +{ + DWORD count; + struct st_cell_data + { + WORD id; + WORD row; + WORD col; + WORD xf; + BYTE* str; // String value; + double d; + int32_t l; + WORD width; // Width of col + WORD colspan; + WORD rowspan; + BYTE isHidden; // Is cell hidden + } + * cell; +} +st_cell; + + +typedef struct st_row +{ + // DWORD count; + WORD lastcol; // numCols - 1 + WORD lastrow; // numRows - 1 + struct st_row_data + { + WORD index; + WORD fcell; + WORD lcell; + WORD height; + WORD flags; + WORD xf; + BYTE xfflags; + st_cell cells; + } + * row; +} +st_row; + + +typedef struct st_colinfo +{ + DWORD count; //Count of COLINFO + struct st_colinfo_data + { + WORD first; + WORD last; + WORD width; + WORD xf; + WORD flags; + } + * col; +} +st_colinfo; + +typedef struct xlsWorkBook +{ + //FILE* file; + OLE2Stream* olestr; + int32_t filepos; // position in file + + //From Header (BIFF) + BYTE is5ver; + BYTE is1904; + WORD type; + + //Other data + WORD codepage; //Charset codepage + char* charset; + st_sheet sheets; + st_sst sst; //SST table + st_xf xfs; //XF table + st_font fonts; + st_format formats; //FORMAT table + + char *summary; // ole file + char *docSummary; // ole file +} +xlsWorkBook; + +typedef struct xlsWorkSheet +{ + DWORD filepos; + WORD defcolwidth; + st_row rows; + xlsWorkBook *workbook; + st_colinfo colinfo; +} +xlsWorkSheet; + +#ifdef __cplusplus +typedef struct st_cell::st_cell_data xlsCell; +typedef struct st_row::st_row_data xlsRow; +#else +typedef struct st_cell_data xlsCell; +typedef struct st_row_data xlsRow; +#endif + +typedef struct xls_summaryInfo +{ + BYTE *title; + BYTE *subject; + BYTE *author; + BYTE *keywords; + BYTE *comment; + BYTE *lastAuthor; + BYTE *appName; + BYTE *category; + BYTE *manager; + BYTE *company; +} +xlsSummaryInfo; + +typedef void (*xls_formula_handler)(WORD bof, WORD len, BYTE *formula); + +#endif diff --git a/app/libxls/include/libxls/xlstool.h b/app/libxls/include/libxls/xlstool.h new file mode 100644 index 0000000..a54633b --- /dev/null +++ b/app/libxls/include/libxls/xlstool.h @@ -0,0 +1,52 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * This file is part of libxls -- A multiplatform, C/C++ library + * for parsing Excel(TM) files. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY David Hoerl ''AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David Hoerl OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Copyright 2004 Komarov Valery + * Copyright 2006 Christophe Leitienne + * Copyright 2013 Bob Colbert + * Copyright 2008-2013 David Hoerl + * + */ + +#include "libxls/xlsstruct.h" + +extern void dumpbuf(BYTE* fname,long size,BYTE* buf); +extern void verbose(char* str); + +extern BYTE *utf8_decode(BYTE *str, DWORD len, char *encoding); +extern BYTE* unicode_decode(const BYTE *s, int len, size_t *newlen, const char* encoding); +extern BYTE* get_string(BYTE *s,BYTE is2, BYTE isUnicode, char *charset); +extern DWORD xls_getColor(const WORD color,WORD def); + +extern void xls_showBookInfo(xlsWorkBook* pWB); +extern void xls_showROW(struct st_row_data* row); +extern void xls_showColinfo(struct st_colinfo_data* col); +extern void xls_showCell(struct st_cell_data* cell); +extern void xls_showFont(struct st_font_data* font); +extern void xls_showXF(XF8* xf); +extern void xls_showFormat(struct st_format_data* format); +extern BYTE* xls_getfcell(xlsWorkBook* pWB,struct st_cell_data* cell,WORD *label); +extern char* xls_getCSS(xlsWorkBook* pWB); +extern void xls_showBOF(BOF* bof); diff --git a/app/libxls/include/libxls/xlstypes.h b/app/libxls/include/libxls/xlstypes.h new file mode 100644 index 0000000..59d64f8 --- /dev/null +++ b/app/libxls/include/libxls/xlstypes.h @@ -0,0 +1,56 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * This file is part of libxls -- A multiplatform, C/C++ library + * for parsing Excel(TM) files. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY David Hoerl ''AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David Hoerl OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Copyright 2004 Komarov Valery + * Copyright 2006 Christophe Leitienne + * Copyright 2013 Bob Colbert + * Copyright 2008-2013 David Hoerl + * + */ + +#ifndef XLS_TYPES_INC +#define XLS_TYPES_INC + +#include <stdint.h> + +typedef unsigned char BYTE; +typedef uint16_t WORD; +typedef uint32_t DWORD; + +#ifdef NO_ALIGN +typedef uint16_t WORD_UA; +typedef uint32_t DWORD_UA; +#else + +#ifdef _WIN32 +typedef __declspec(align(1)) uint16_t WORD_UA; +typedef __declspec(align(1)) uint32_t DWORD_UA; +#else +typedef uint16_t WORD_UA __attribute__((aligned(1))); // 2 bytes +typedef uint32_t DWORD_UA __attribute__((aligned(1))); // 4 bytes +#endif + +#endif +#endif diff --git a/app/libxls/include/xls.h b/app/libxls/include/xls.h new file mode 100644 index 0000000..b87cb73 --- /dev/null +++ b/app/libxls/include/xls.h @@ -0,0 +1,76 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * This file is part of libxls -- A multiplatform, C/C++ library + * for parsing Excel(TM) files. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY David Hoerl ''AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David Hoerl OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Copyright 2004 Komarov Valery + * Copyright 2006 Christophe Leitienne + * Copyright 2008-2012 David Hoerl + * + */ + +#ifndef XLS_INCLUDE +#define XLS_INCLUDE + +#ifdef __cplusplus +namespace xls { +extern "C" { +#endif + +#include "libxls/xlstypes.h" +#include "libxls/xlsstruct.h" +#include "libxls/xlstool.h" + + +#define BLANK_CELL 0x0201 + + +extern const char* xls_getVersion(void); + +extern int xls(int debug); // Set debug. Force library to load? +extern void xls_set_formula_hander(xls_formula_handler handler); + +extern void xls_parseWorkBook(xlsWorkBook* pWB); +extern void xls_parseWorkSheet(xlsWorkSheet* pWS); + +extern xlsWorkBook* xls_open(const char *file,const char *charset); // convert 16bit strings within the spread sheet to this 8-bit encoding (UTF-8 default) +#define xls_close xls_close_WB // historical +extern void xls_close_WB(xlsWorkBook* pWB); // preferred name + +extern xlsWorkSheet * xls_getWorkSheet(xlsWorkBook* pWB,int num); +extern void xls_close_WS(xlsWorkSheet* pWS); + +extern xlsSummaryInfo *xls_summaryInfo(xlsWorkBook* pWB); +extern void xls_close_summaryInfo(xlsSummaryInfo *pSI); + +// utility function +xlsRow *xls_row(xlsWorkSheet* pWS, WORD cellRow); +xlsCell *xls_cell(xlsWorkSheet* pWS, WORD cellRow, WORD cellCol); + +#ifdef __cplusplus +} // extern c block +} // namespace +#endif + +#endif + diff --git a/app/libxls/lib/endian.o b/app/libxls/lib/endian.o new file mode 100644 index 0000000..7c8109b --- /dev/null +++ b/app/libxls/lib/endian.o Binary files differ diff --git a/app/libxls/lib/libxls.def b/app/libxls/lib/libxls.def new file mode 100644 index 0000000..bf545b0 --- /dev/null +++ b/app/libxls/lib/libxls.def @@ -0,0 +1,76 @@ +EXPORTS + brdb @1 DATA + dumpbuf @2 + get_string @3 + ole2_bufread @4 + ole2_close @5 + ole2_fclose @6 + ole2_fopen @7 + ole2_open @8 + ole2_read @9 + ole2_seek @10 + ole2_sopen @11 + unicode_decode @12 + utf8_decode @13 + verbose @14 + xls @15 + xlsConvertBiff @16 + xlsConvertBof @17 + xlsConvertBoundsheet @18 + xlsConvertCol @19 + xlsConvertColinfo @20 + xlsConvertDouble @21 + xlsConvertFont @22 + xlsConvertFormat @23 + xlsConvertFormula @24 + xlsConvertFormulaArray @25 + xlsConvertHeader @26 + xlsConvertMergedcells @27 + xlsConvertPss @28 + xlsConvertRow @29 + xlsConvertSst @30 + xlsConvertWindow @31 + xlsConvertXf5 @32 + xlsConvertXf8 @33 + xlsIntVal @34 + xlsShortVal @35 + xls_addCell @36 + xls_addColinfo @37 + xls_addFont @38 + xls_addFormat @39 + xls_addRow @40 + xls_addSST @41 + xls_addSheet @42 + xls_addXF5 @43 + xls_addXF8 @44 + xls_appendSST @45 + xls_cell @46 + xls_close_WB @47 + xls_close_WS @48 + xls_close_summaryInfo @49 + xls_debug @50 DATA + xls_dumpSummary @51 + xls_formatColumn @52 + xls_getCSS @53 + xls_getColor @54 + xls_getVersion @55 + xls_getWorkSheet @56 + xls_getfcell @57 + xls_is_bigendian @58 + xls_makeTable @59 + xls_mergedCells @60 + xls_open @61 + xls_parseWorkBook @62 + xls_parseWorkSheet @63 + xls_preparseWorkSheet @64 + xls_row @65 + xls_set_formula_hander @66 + xls_showBOF @67 + xls_showBookInfo @68 + xls_showCell @69 + xls_showColinfo @70 + xls_showFont @71 + xls_showFormat @72 + xls_showROW @73 + xls_showXF @74 + xls_summaryInfo @75 diff --git a/app/libxls/lib/libxls.dll b/app/libxls/lib/libxls.dll new file mode 100644 index 0000000..87ebf62 --- /dev/null +++ b/app/libxls/lib/libxls.dll Binary files differ diff --git a/app/libxls/lib/libxls.exp b/app/libxls/lib/libxls.exp new file mode 100644 index 0000000..456556e --- /dev/null +++ b/app/libxls/lib/libxls.exp Binary files differ diff --git a/app/libxls/lib/libxls.lib b/app/libxls/lib/libxls.lib new file mode 100644 index 0000000..cbfb568 --- /dev/null +++ b/app/libxls/lib/libxls.lib Binary files differ diff --git a/app/libxls/lib/libxlsreader.a b/app/libxls/lib/libxlsreader.a new file mode 100644 index 0000000..6a89fbb --- /dev/null +++ b/app/libxls/lib/libxlsreader.a Binary files differ diff --git a/app/libxls/lib/libxlsreader.la b/app/libxls/lib/libxlsreader.la new file mode 100644 index 0000000..3aa3f9d --- /dev/null +++ b/app/libxls/lib/libxlsreader.la @@ -0,0 +1,41 @@ +# libxlsreader.la - a libtool library file +# Generated by libtool (GNU libtool) 2.2.10 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='' + +# Names of this library. +library_names='' + +# The name of the static archive. +old_library='libxlsreader.a' + +# Linker flags that can not go in dependency_libs. +inherited_linker_flags='' + +# Libraries that this one depends upon. +dependency_libs=' -liconv' + +# Names of additional weak libraries provided by this library +weak_library_names='' + +# Version information for libxlsreader. +current=3 +age=2 +revision=1 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/usr/local/libxls/lib' diff --git a/app/libxls/lib/ole.o b/app/libxls/lib/ole.o new file mode 100644 index 0000000..9b5480c --- /dev/null +++ b/app/libxls/lib/ole.o Binary files differ diff --git a/app/libxls/lib/xls.o b/app/libxls/lib/xls.o new file mode 100644 index 0000000..08d090b --- /dev/null +++ b/app/libxls/lib/xls.o Binary files differ diff --git a/app/libxls/lib/xlstool.o b/app/libxls/lib/xlstool.o new file mode 100644 index 0000000..ff3c40f --- /dev/null +++ b/app/libxls/lib/xlstool.o Binary files differ diff --git a/app/resource.h b/app/resource.h index 1c9aa57..0fb9e5b 100644 --- a/app/resource.h +++ b/app/resource.h @@ -50,6 +50,7 @@ #define IDC_CHECK_TRADE_TIME_DELEGATE 1044 #define IDC_CHECK_TRADE_TIME_TRADE_SUCCESS 1045 #define IDC_CHECK_TRADE_TIME_LIMIT_UP 1046 +#define IDC_BUTTON_UPLOAD_EXCEL_CODE 1047 // Next default values for new objects // @@ -57,7 +58,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 136 #define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1045 +#define _APS_NEXT_CONTROL_VALUE 1048 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/app/user.txt b/app/user.txt index cd7ecd6..6ffb317 100644 --- a/app/user.txt +++ b/app/user.txt @@ -1,3 +1,3 @@ -client3 +admin 123456 0 \ No newline at end of file -- Gitblit v1.8.0