请到这里下载libxl.lib:http://download.csdn.net/download/qq_36576377/10206819
1.设置:
2.代码示例:
#include <iostream>
#include <windows.h>
#include "libxl.h"
#pragma comment(lib,"libxl.lib")
using namespace libxl;
int main()
{
Book* book = xlCreateBook();
book->setKey(L"Halil Kural", L"windows-2723210a07c4e90162b26966a8jcdboe");
if (book)
{
Sheet* sheet = book->addSheet(L"Sheet1");
if (sheet)
{
sheet->writeStr(2, 1, L"Hello, World !");
sheet->writeNum(4, 1, 1000);
sheet->writeNum(95, 1, 2000);
sheet->writeNum(105, 1, 2000);
Font* font = book->addFont();
font->setColor(COLOR_RED);
font->setBold(true);
Format* boldFormat = book->addFormat();
boldFormat->setFont(font);
sheet->writeFormula(6, 1, L"SUM(B5:B6)", boldFormat);
Format* dateFormat = book->addFormat();
dateFormat->setNumFormat(NUMFORMAT_DATE);
sheet->writeNum(8, 1, book->datePack(2008, 4, 29), dateFormat);
sheet->setCol(1, 1, 12);
}
if (book->save(L"example.xls"))
{
::ShellExecute(NULL, L"open", L"example.xls", NULL, NULL, SW_SHOW);
}
else
{
std::cout << book->errorMessage() << std::endl;
}
book->release();
}
return 0;
}