libxl 的使用,读取时间格式
最近开发使用到 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 的使用,读取时间格式的更多相关文章
- poi导入读取时间格式问题
万能处理方案: 所有日期格式都可以通过getDataFormat()值来判断 yyyy-MM-dd-----14 yyyy年m月d日--- 31 yyyy年m月-------57 m月d日 ---- ...
- 使用POI读取xlsx文件,包含对excel中自定义时间格式的处理
package poi; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundExcepti ...
- NPOI 读取excel的时候,时间格式的处理
excel的时间格式是:CellType.Numeric 要判断时间还需要方法:DateUtil.IsCellDateFormatted(cell)的帮助: 示例代码如下: ICell cell = ...
- iOSDate时间格式(转)
在开发iOS程序时,有时候需要将时间格式调整成自己希望的格式,这个时候我们可以用NSDateFormatter类来处理.例如: //实例化一个NSDateFormatter对象 NSDateForma ...
- iOS开发之时间格式的转化
在开发iOS程序时,有时候需要将时间格式调整成自己希望的格式,这个时候我们可以用NSDateFormatter类来处理. 例如:如何将格式为“12-May-14 05.08.02.000000 PM” ...
- POI教程之第二讲:创建一个时间格式的单元格,处理不同内容格式的单元格,遍历工作簿的行和列并获取单元格内容,文本提取
第二讲 1.创建一个时间格式的单元格 Workbook wb=new HSSFWorkbook(); // 定义一个新的工作簿 Sheet sheet=wb.createSheet("第一个 ...
- IOS时间格式转换
在开发iOS程序时,有时候需要将时间格式调整成自己希望的格式,这个时候我们可以用NSDateFormatter类来处理. 例如:如何将格式为“12-May-14 05.08.02.000000 PM” ...
- IOS 时间格式 时间转换 大总结
//实例化一个NSDateFormatter对象 NSDateFormatter *dateFormatter = [[NSDateFormatteralloc] init]; //设定时间格式,这里 ...
- Eclipse 改动凝视的 date time 日期时间格式,即${date}变量格式
Eclipse 改动凝视的 date time 日期时间格式,即${date}变量格式 找到eclipse安装文件夹以下的plugins文件夹,搜索 org.eclipse.text ,找到一个jar ...
随机推荐
- python脚本监控获取当前Linux操作系统[内存]/[cpu]/[硬盘]/[登录用户]
此脚本应用在linux, 前提是需要有python和python的psutil模块 脚本 #!/usr/bin/env python # coding=utf-8 import sys import ...
- linux的dns被劫持
环境:ubuntu16.04 解说:ubuntu使用dnsmasq获取要解析的网站ip,dnsmasq通过域名服务器获取网站ip,并将ip缓存起来,那么就可以减少对外网域名服务器的访问,从而可以使系统 ...
- ubuntu查询某个库的相关情况
环境:Ubuntu 14.04 64bit 1.如:查询libjpeg库的位置 ldconfig -p |grep libjpeg 2.如:查询libjpeg库的相关名称 dpkg -l '*jpeg ...
- JavaScript:Object属性方法
Object的属性(firebug中没有找到) var pro={ city:"shanghai", list:[,,,,] } var Person=function(name, ...
- JavaScript紧凑学习
JavaScript紧凑学习 windows本地,调用命令行: win键+R 键入cmd , (cmd是Command 命令行 简称) 目录是C盘下的 C:\Users\Administrator&g ...
- vs2010中自动给函数或者类加上注释宏模板
Sub AddFunComment() Dim DocSel As EnvDTE.TextSelection DocSel = DTE.ActiveDocument.Selection DocSel. ...
- LA 3027 合作网络
https://vjudge.net/problem/UVALive-3027 题意: 有n个结点,初始时每个结点的父节点都不存在.你的任务是执行一次I操作和E操作,格式如下: I u v:把结点u的 ...
- UVa 12563 劲歌金曲(0-1背包)
https://vjudge.net/problem/UVA-12563 题意: 在一定的时间内连续唱歌,最后一首唱11分钟18秒的劲歌金曲,问最多能长多长时间. 思路: 0-1背包问题,背包容量为t ...
- Eclipse如何快速改变主题颜色
厌倦了Eclipse的白底黑子,我们来更换下Eclipse的主题颜色,让眼睛更舒服一点 首先先进入网址:http://eclipsecolorthemes.org/ 选择一个主题进入,点击进入如下: ...
- 《剑指offer》第四十题(最小的k个数)
// 面试题40:最小的k个数 // 题目:输入n个整数,找出其中最小的k个数.例如输入4.5.1.6.2.7.3.8 // 这8个数字,则最小的4个数字是1.2.3.4. #include < ...