欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: libxl-3.1.0下載 可操作excel,不依賴excel安裝環境 [打印本頁]

作者: wangfans    時間: 2017-9-1 12:22
標題: libxl-3.1.0下載 可操作excel,不依賴excel安裝環境
我們常用ole方式操作excel,需要安裝excel,并且如果訪問越界會runtime error。
采用libxl操作excel,不依賴excel安裝環境。直接讀取excel,并且不會出現runtime error。非常方便。


所有資料51hei提供下載:
libxl-3.1(破解版).rar (3.27 MB, 下載次數: 15)



源程序如下:
  1. #include <iostream>
  2. #include <libxl.h>
  3. #include <Windows.h>

  4. using namespace std;
  5. using namespace libxl;

  6. //中文的內容讀出來后要進行編碼的轉換,這個為轉換函數:wchar_t to char
  7. char *w2c(char *pcstr,const wchar_t *pwstr, size_t len)

  8. {
  9.         int nlength=wcslen(pwstr);
  10.         //獲取轉換后的長度
  11.         int nbytes = WideCharToMultiByte( 0, 0, pwstr, nlength, NULL,0,NULL, NULL );
  12.         if(nbytes>len)   nbytes=len;
  13.         // 通過以上得到的結果,轉換unicode 字符為ascii 字符
  14.         WideCharToMultiByte( 0,0, pwstr, nlength,   pcstr, nbytes, NULL,   NULL );
  15.         return pcstr ;
  16. }

  17. int main(int argc, char* argv[])
  18. {
  19.         Book* book = xlCreateXMLBook();
  20.         if(book->load(L"1.xlsx")){
  21.                 Sheet * sheet = book->getSheet(0);
  22.                 if(sheet){
  23.                         CellType celltype = sheet->cellType(1,1);
  24.                         cout<<"the type is:"<<celltype<<endl;

  25.             const wchar_t * t = sheet->readStr(1,1);
  26.                         char *pcstr = (char *)malloc(sizeof(char)*(2 * wcslen(t)+1));
  27.                         memset(pcstr , 0 , 2 * wcslen(t)+1 );
  28.                         w2c(pcstr,t,2 * wcslen(t)+1) ;
  29.                         cout<<"result:"<<pcstr<<endl;
  30.                         free(pcstr);
  31.                 }
  32.         }
  33.         system("pause");
  34.         return 0;
  35. }
復制代碼






作者: xinqinglhj    時間: 2017-9-13 10:53
沒有用過不知道好不好用。




歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1