目的说明:Visual Studio2010开发C++程序,调用ExcelFormat库进行Excel的读写操作。
使用方法:
(1)将源文件中的BasicExcel.cpp、BasicExcel.hpp、ExcelFormat.cpp、ExcelFormat.h直接加入到工程中。
将上述四个文件直接加入到工程可能遇到到问题与解决方法:可能错误一:fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h
可能错误二:error LNK2038: 检测到“_ITERATOR_DEBUG_LEVEL”的不匹配项: 值“0”不匹配值“2”
(2)ExcelFormat库的使用方法
1.调用处添加头文件和命名空间
#include "ExcelFormat.h"
using namespace ExcelFormat;
2.功能实现
下面给出一个例子:
//save data into excel file at selected position
BasicExcel xls;
// create sheet 1 and get the associated BasicExcelWorksheet pointer
xls.New(1);
BasicExcelWorksheet* sheet = xls.GetWorksheet(0);
XLSFormatManager fmt_mgr(xls);
// 设置Excel表格中的字体
ExcelFont font_bold;
font_bold._weight = FW_BOLD; // 700
CellFormat fm