编译xlnt开源库源码, 使用c++读写excel文件

编译xlnt开源库源码,在linux平台使用c++读写excel文件
下载xnlt源码
官方网站https://tfussell.gitbooks.io/xlnt/content/
下载地址https://github.com/tfussell/xlnt
下载libstudxml开源库源码
下载地址https://github.com/kamxgal/libstudxml

下载xnlt源码

官方网站https://tfussell.gitbooks.io/xlnt/content/

下载地址https://github.com/tfussell/xlnt
获取到xlnt-master.zip

下载libstudxml开源库源码
下载地址https://github.com/kamxgal/libstudxml
获取到libstudxml-master.zip

编译步骤

将libstudxml-master/libstudxml拷贝到xlnt-master/third-party/libstudxml

注意:是这个xlnt-master/third-party/libstudxml目录下,拷贝的结果是xlnt-master/third-party/libstudxml/libstudxml

4 在xlnt-master目录下创建build目录,创建命令:

mkdir build
5 在切换到build目录下,执行命令:

cd build
6 cmake -D STATIC=ON … (指定生成的为静态库)
7 cmake --build .
xlnt-master/build/source/libxlnt.a是生成的静态库,对应的头文件在xlnt-master/include/里面

注意: xlnt::workbook类的load(std::string path)在读取excel文件时,如果excel文件不存在直接抛出异常,程序退出。可能需要先用文件流先判断文件时候存在,demo如下,dest_filename为目标excel文件路径。

std::ifstream file_stream;
file_stream.open(dest_filename, std::ios::binary);
if (!file_stream.good())
{
std::clog << “ERROR ***************************************************” << std::endl;
return -1;
}
xlnt::workbook wb_read;
wb_read.load(“dest_filename”);
————————————————

    

3:cmake xlnt  ,命令如下

cd xlnt-master

mkdir build

cd build

二、构建、编译、运行

cmake -G “Visual Studio 12 2013 Win64” ..

cmake -G “Visual Studio 12 2013” ..

cmake ..

4.用vs打开xlnt-master\build\xlnt_all.sln,生成解决方案

5.在 xlnt-master\include中得到头文件,在xlnt-master\build\source\Debug中得到动态链接库

编译库文件

进入build文件夹,打开sln文件

选择模式Debug或者Release,点击运行。

输出显示到已生成dll文件,即生成完毕。

生成库的路径如下。

  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值