libxl库 学习,读写excel中数据
来源:互联网 发布:淘宝店铺如何开通微淘 编辑:程序博客网 时间:2024/05/05 05:41
程序如下:
#include "stdafx.h"#include <iostream>#include "include_cpp/libxl.h"using namespace libxl;using namespace std; int _tmain(int argc, _TCHAR* argv[]){Book* book = xlCreateBook(); // xlCreateXMLBook() for xlsxif(book){Sheet* sheet = book->addSheet(L"Sheet1");if(sheet){sheet->writeStr(2, 1, L"Hello, World !");sheet->writeNum(3, 1, 1000);}book->save(L"example.xls");book->release();} return 0;}
配置:
1、把include_cpp 和libxl.lib,libxl.dll文件放到工程中。并在属性---VC++目录,包含这个目录
2、依赖项中加入Libxl.lib库
3、包含#include "include_cpp/libxl.h"
using namespace libxl;
以下程序是把一个excel表格中的数据写入到 MNIST手写体识别 文件中,
写入4个字节的数据,读4个字节的数据,去掉了文件头
#include "stdafx.h"#include <iostream>#include <iostream>#include <fstream>#include <opencv2/opencv.hpp>#include "include_cpp/libxl.h"using namespace libxl;using namespace std;using namespace cv;/*#define NUMBER_OF_TRAINING_SAMPLES 60000#define ATTRIBUTES_PER_SAMPLE 784#define NUMBER_OF_TESTING_SAMPLES 10000#define NUMBER_OF_CLASSES 10*/#define NUMBER_OF_TRAINING_SAMPLES 5120 //训练样本个数#define ATTRIBUTES_PER_SAMPLE 21 //有多少列#define NUMBER_OF_TESTING_SAMPLES 825 //测试样本个数#define NUMBER_OF_CLASSES 4 //种类个数int _tmain(int argc, _TCHAR* argv[]){ofstream outfile1,outfile2;outfile1.open("train-images.idx3-ubyte",ios::binary);outfile2.open("train-labels.idx1-ubyte",ios::binary);//表示需要读出测试样例ofstream testfile1,testfile2;testfile1.open("t10k-images.idx3-ubyte",ios::binary);testfile2.open("t10k-labels.idx1-ubyte",ios::binary);Book *book = xlCreateBook(); // xlCreateXMLBook() for xlsxCellType ct;bool f=book->load("testnewdata.xls");Sheet *sheet =book->getSheet(0); int cellnum; int label;//写训练数据与labelfor (int i=0;i<NUMBER_OF_TRAINING_SAMPLES;i++){for (int j=1;j<ATTRIBUTES_PER_SAMPLE+1;j++){//ct = sheet->cellType(i,j);//单元格的数据类型 1表示是数字 2表示是字符串cellnum = (int)sheet->readNum(i,j);outfile1.write((char *)&cellnum ,4); //s = sheet->readStr(i,j);//outfile1.write(s ,1);}label = sheet->readNum(i,0);outfile2.write((char *)&label,4);}//写测试数据与labelfor (int i=0;i<NUMBER_OF_TESTING_SAMPLES;i++){for (int j=1;j<ATTRIBUTES_PER_SAMPLE+1;j++){//ct = sheet->cellType(i,j);//单元格的数据类型 1表示是数字 2表示是字符串cellnum = sheet->readNum(i,j);testfile1.write((char *)&cellnum ,4);}label = sheet->readNum(i,0);testfile2.write((char *)&label,4);} outfile1.close(); outfile2.close(); testfile1.close(); testfile2.close();return 0;}
0 0
- libxl库 学习,读写excel中数据
- libxl 学习之 excel 读写操作
- Visual Studio 2010利用libxl读写excel表格数据
- 【mfc】excel读写——libxl.lib库
- C++ 读取excel 之libxl VS 库的配置使用
- C++ 读写Excel表格文件 Libxl破解版 支持2007版本 xlsx 中文
- MATLAB学习(四)Excel读写数据
- libxl库的使用
- MatLab建模学习笔记4——MatLab向Excel中读写数据
- poi读写excel数据
- javapoi读写数据 excel
- MATLAB 读写excel数据
- MATLAB读写Excel数据
- Oledb读写excel数据
- 从Excel读写数据
- 读写Excel数据
- MATLAB 读写excel数据
- java中怎样从Excel中读写数据
- 【bzoj2597】[Wc2007]剪刀石头布 费用流
- SmartDrv的前世今生——PrimoCache_2.2.0汉化
- 在单文档程序中动态切换多个窗体(附图)
- 如何更新时间戳文件--utimes()简单介绍
- Intent详解 (一) : 显式Intent
- libxl库 学习,读写excel中数据
- 哈理工OJ 2281 11(简单的找规律题目)
- Unity MeshFilter导出OBJ文件
- wpa_supplicant-2.5源码解析
- stm8 clock
- C#笔试题目(综合版样题)
- x264源码分析与应用示例(二)——码率控制
- 如何激活phpstorm/webstorm?
- Android MediaRecorder 录音