最近开发使用到 libxl,用的是3.8.0 破解版。

具体过程:

1、将lib.dll放在exe同目录下,在代码中引用 libxl.lib

  #pragma comment(lib, ".\\Lib\\libxl.lib")

2、包含头文件 libxl.h

3、实例

//m_strFilePath为excel文件的完整路径
CString ext = ::PathFindExtension(m_strFilePath);
if(ext.CompareNoCase(L".xlsx") == 0)
book = xlCreateXMLBook(); //针对.xlsx
else
book = xlCreateBook();  //针对.xls if(!book)
{
return;
} const wchar_t * x = L"Halil Kural";
const wchar_t * y = L"windows-2723210a07c4e90162b26966a8jcdboe";
book->setKey(x, y); //设置key,即破解^_^ if(!book->load(m_strFilePath))
{
return;
} int sheetCount = book->sheetCount(); //工作表总数量
for (int index = 0; index < sheetCount; ++index)
{
Sheet *sheet =book->getSheet(index++);
if(!sheet)
continue;
int firstRow = sheet->firstRow(); //有数据的第一行行号
int lastRow = sheet->lastRow();  //有数据的最后一行行号
int firstCol = sheet->firstCol(); //有数据的第一列列号
int lastCol = sheet->lastCol(); //有数据的最后一列列号 //找出表头(测试数据)
map<int,wstring> mapColNames;
for(int c = firstCol; c < lastCol; ++c)
{
const wchar_t* str = sheet->readStr(firstRow, c);
if(!str)
continue;
mapColNames[c] = str;
} //确定每个表头代表的意义(测试数据)
map<int,eFIELD> mapColTypes;
for (auto it = mapColNames.begin(); it != mapColNames.end(); ++it)
{
eFIELD e = GetFieldTypeByName(it->second.c_str());
mapColTypes[it->first] = e;
} //逐行读取数据
for (int row = firstRow+1; row < lastRow; ++row)
{
for(int c = firstCol; c < lastCol; ++c)
{
CString strValue;
CellType t = sheet->cellType(row, c);
if(t == CELLTYPE_NUMBER)
{
double db = sheet->readNum(row, c);//test
LONG64 number = (LONG64)db;
if(number > 0)
strValue.Format(L"%I64d", number);
}
else
const wchar_t* s = sheet->readStr(row, c); //读取内容
}
         }
}

  

4、读取时间格式的数据

 CString strValue;
bool bDate = sheet->isDate(row, col);
if (bDate)
{
double db = sheet->readNum(row, col);
int year=, month=, day=;
bool b = book->dateUnpack(db, &year, &month, &day); //将读取的时间 转换为时间戳
unsigned __int64 ftNow;
SYSTEMTIME time;
ZeroMemory(&time, sizeof(SYSTEMTIME)),
time.wYear = year;
time.wMonth = month;
time.wDay = day;
SystemTimeToFileTime(&time,(LPFILETIME)&ftNow);
__int64 timeStamp = (__int64)((ftNow-0x019db1ded53e8000)/);//毫秒
strValue.Format(L"%I64d", timeStamp);
}

libxl 的使用,读取时间格式的更多相关文章

  1. poi导入读取时间格式问题

    万能处理方案: 所有日期格式都可以通过getDataFormat()值来判断 yyyy-MM-dd-----14 yyyy年m月d日--- 31 yyyy年m月-------57 m月d日  ---- ...

  2. 使用POI读取xlsx文件,包含对excel中自定义时间格式的处理

    package poi; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundExcepti ...

  3. NPOI 读取excel的时候,时间格式的处理

    excel的时间格式是:CellType.Numeric 要判断时间还需要方法:DateUtil.IsCellDateFormatted(cell)的帮助: 示例代码如下: ICell cell = ...

  4. iOSDate时间格式(转)

    在开发iOS程序时,有时候需要将时间格式调整成自己希望的格式,这个时候我们可以用NSDateFormatter类来处理.例如: //实例化一个NSDateFormatter对象 NSDateForma ...

  5. iOS开发之时间格式的转化

    在开发iOS程序时,有时候需要将时间格式调整成自己希望的格式,这个时候我们可以用NSDateFormatter类来处理. 例如:如何将格式为“12-May-14 05.08.02.000000 PM” ...

  6. POI教程之第二讲:创建一个时间格式的单元格,处理不同内容格式的单元格,遍历工作簿的行和列并获取单元格内容,文本提取

    第二讲 1.创建一个时间格式的单元格 Workbook wb=new HSSFWorkbook(); // 定义一个新的工作簿 Sheet sheet=wb.createSheet("第一个 ...

  7. IOS时间格式转换

    在开发iOS程序时,有时候需要将时间格式调整成自己希望的格式,这个时候我们可以用NSDateFormatter类来处理. 例如:如何将格式为“12-May-14 05.08.02.000000 PM” ...

  8. IOS 时间格式 时间转换 大总结

    //实例化一个NSDateFormatter对象 NSDateFormatter *dateFormatter = [[NSDateFormatteralloc] init]; //设定时间格式,这里 ...

  9. Eclipse 改动凝视的 date time 日期时间格式,即${date}变量格式

    Eclipse 改动凝视的 date time 日期时间格式,即${date}变量格式 找到eclipse安装文件夹以下的plugins文件夹,搜索 org.eclipse.text ,找到一个jar ...

随机推荐

  1. SIFT特征原理简析(HELU版)

    SIFT(Scale-Invariant Feature Transform)是一种具有尺度不变性和光照不变性的特征描述子,也同时是一套特征提取的理论,首次由D. G. Lowe于2004年以< ...

  2. React 回忆录(二)为什么使用 React?

    Hi 各位,欢迎来到 React 回忆录!

  3. DSDS,双模,双卡,双待,单待,双通,单通,概念及相互关系?【转】

    本文转载自:https://blog.csdn.net/dirk_it/article/details/7178058?utm_source=blogxgwz9 DSDS:双卡双待 DualSimDu ...

  4. Python 中的几种矩阵乘法 np.dot, np.multiply, *【转】

    本文转载自:https://blog.csdn.net/u012609509/article/details/70230204 Python中的几种矩阵乘法1. 同线性代数中矩阵乘法的定义: np.d ...

  5. fhq treap抄袭笔记

    目录 碎碎念 点一下 注意!!! 模板 fhq treap 碎碎念 我咋感觉合并这么像左偏树呢 ps:难道你们的treap都是小头堆的吗 fhq真的是神人 现在看以前学的splay是有点恶心,尤其是压 ...

  6. Wireshark无法解析OpenFlow配置协议 解决方法

    在使用wireshark对OpenFlow交换机与FlowVisor的通信过程进行抓包分析的时候,在其选项中有openflow_v1选项,但Wireshark竟无法解析OpenFlow协议. 在查阅相 ...

  7. 高精度N的阶乘-N!

    题目:输入一个正整数N(0<N<=30),求N! 代码: #include<stdlib.h> #include<cstdio> #include<strin ...

  8. python 编程基础练习 第一天

    python 编程基础练习 第一天: 需求: 1.计算2的38次方,180*0.7输出(精度显示正常), x的y次方,数字倒序输出即345876输出678543,方法越多越好. 2.字符串处理: 1) ...

  9. MyBatis各种类型的入参使用方式

    https://blog.csdn.net/u011983531/article/details/53561219 mybatis中if判断传入字符串或者Long参数不为空 https://blog. ...

  10. Codeforces Beta Round #95 (Div. 2) D. Subway dfs+bfs

    D. Subway A subway scheme, classic for all Berland cities is represented by a set of n stations conn ...