这个例子显示了如何从内存缓冲区读取Excel电子表格。
LibXL是一个轻量级的Excel类库,支持各类平台运行,如需使用先行点击这里下载:
#include "libxl.h"#include <iostream>#include <fstream>using namespace libxl;int main(){ std::fstream stream("input.xls", std::ios_base::in | std::ios_base::binary); if(!stream) { std::cout << "file not found" << std::endl; return 1; } stream.seekg(0, std::ios_base::end); unsigned size = stream.tellg(); char* buf = new char[size]; stream.seekg(0, std::ios_base::beg); stream.read(buf, size); Book* book = xlCreateBook(); if(book->loadRaw(buf, size)) { Sheet* sheet = book->getSheet(0); std::wcout << sheet->name() << std::endl; } else { std::cout << book->errorMessage() << std::endl; return 1; } delete[] buf; return 0;}
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!