c++操作excel的几种库

OpenXLSX

链接https://github.com/troldal/OpenXLSX:

OpenXLSX 是一个 C++ 库,用于读取、写入、创建和修改 Microsoft Excel 文件,采用 .xlsx 格式。

注意: 这库我测试时对中文utf-8支持不行,创建的xlsx文件中有中文就打不开,提示文件破损。

虽然他说一秒读写400万单元格。

兼容性:
在这里插入图片描述

libxlsxwriter

链接:https://github.com/jmcnamara/libxlsxwriter

Libxlsxwriter 是一个 C 库,可用于在 Excel 2007+ XLSX 文件中写入文本、数字、公式和指向多个工作表的超链接。

它支持以下功能:
100% 兼容 Excel XLSX 文件。
完整的 Excel 格式。
合并的单元格。
定义的名称。
自动过滤器。
图表。
数据验证和下拉列表。
条件格式。
工作表 PNG/JPEG/GIF 图像。
单元格评论。
支持添加宏。
用于写入大文件的内存优化模式。
源代码可在GitHub 上获得。
FreeBSD 许可证。
ANSI C.
适用于 GCC、Clang、Xcode、MSVC 2015、ICC、TCC、MinGW、MingGW-w64/32。
适用于 Linux、FreeBSD、OpenBSD、OS X、iOS 和 Windows。也适用于 MSYS/MSYS2 和 Cygwin。
编译为 32 位和 64 位。
在大端和小端系统上编译和工作。
唯一的依赖是在zlib。

官网文档:http://libxlsxwriter.github.io/

readxl

readxl 包可以轻松地从 Excel 中获取数据并导入 R。与许多现有包(例如 gdata、xlsx、xlsReadWrite)相比,readxl 没有外部依赖项,因此它易于在所有操作系统上安装和使用。它旨在读取表格数据。

它比 openxlsx 简约得多,但在简单的例子中,它的速度似乎是它的两倍,并且可以编写更小的文件。

链接:https://github.com/tidyverse/readxl

xlslib

链接:http://xlslib.sourceforge.net/index.php

涉及到跨平台,同时又要对Excel的读写操作兼顾,而且免费的库,那应该是要用xlslib和libxls了。xlslib库只能写Excel文件,libxls库只能读Excel文件。另外libxl库功能强大,但是收费的

BasicExcel

这库还没试

这是曾经做过的一个项目时写的一个动态,用c++操作Excel,包括以下功能: //===================================mainly function============================ //FuncName: xls_create //function: create excel server //return value: return 1 if success, otherwise 0 _export bool xls_create(); //FuncName: xls_new_file/xls_new_file2 //function: create an excel file (from a template) //parameter: strTemplate ->excel template file name,eg: "template.xlt" or "d:\teplate.xls" // strFileName ->the file name used to save excel file as,eg: "Temp.xls" // openfile ->1: open excel file after writen it,otherwize don't open it //return value: return the excel fileID which created from template, between 1 and 256 if success, or zero otherwise _export int xls_new_file(char* szTemplate, char* szFileName, int openfile); _export int xls_new_file2(char* szFileName, int openfile); //FuncName: xls_open_file //function: Open an exist excel file //parameter:the file name will to be opened //return value: return the fileID, if open file success,otherwize return 0 _export int xls_open_file(char* szFileName); //FuncName: xls_write_xxx //function: write a double value to xls file //parameter: fileID ->the excel file ID which we will write the value into,between 1 and 256 // sheetID ->the sheet index of the excel file which we will write the value into,between 1 and 256 // crow ->the row index which we will write the value into, not less 1 // ccol ->the column index which we will write the value into, not less 1 // value ->the double value which we will write into excel //Note: if you want to input enter key in excel file,you may use \n in your str //return value: return 1 if success, otherwise 0 _export int xls_write_str(int fileID, int sheetID, int crow, int ccol, char* value); _export int xls_write_dbl(int fileID, int sheetID, int crow, int ccol, double value); _export int xls_write_int(int fileID, int sheetID, int crow, int
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值