采用xlsxwriter开源库的实现,声明如下:
#include "./xlsxwriter/include/xmlwriter.h"
#include "./xlsxwriter/include/workbook.h"
#include "./xlsxwriter/include/worksheet.h"
#ifdef _DEBUG
#pragma comment(lib, "./xlsxwriter/lib/debug/xlsxwriter.lib")
#else
#pragma comment(lib, "./xlsxwriter/lib/release/xlsxwriter.lib")
#endif // _DEBUG
//创建工作簿
lxw_workbook *workbook = workbook_new(CStrUtils::AnsiToUtf8("D:\\测试.xlsx"));
//创建分页
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, "Sheet1");
//写入数据
worksheet_write_string(worksheet, 0, 0, "Row-0 Column-0", NULL);
worksheet_write_string(worksheet, 0, 1, "Row-0 Column-1", NULL);
//保存文档
lxw_error err = workbook_close(workbook);
if (LXW_NO_ERROR != err) {
//保存失败
}
版权声明:本文为u012156872原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。