BasicExcel
使用 BasicExcel 库实现读写 Excel 文件,该库可以实现 Excel 文件的基本操作,中文支持良好,不依赖其它应用程序。
下载地址:http://shell.franken.de/svn/sky/excel/trunk/
基本操作:
- 该库使用命名空间为 ExcelFormat,为方便使用将命名空间重命名为 BE
- 初始化
BE::BasicExcel wb; wb.New(1); //初始化一个workbook BE::BasicExcelWorksheet *ws = wb.GetWorksheet(0);//获取第一个worksheet
- 写入数据
Worksheet 成员函数 Cell()获取 ExcelCell 对象,ExcelCell 的成员函数 set 设置单元格内容。
成员函数 Set 有下面四个重载,中文字符需要转为 Unicode 再写入 Excelws->Cell(r, c)->Set(text.operator cWStringT()); //写入Unicode字符串
void Set(int val); ///< Set content of current Excel cell to an integer. void Set(double val); ///< Set content of current Excel cell to a double. void Set(const char *str); ///< Set content of current Excel cell to an ANSI string. void Set(const wchar_t *str); ///< Set content of current Excel cell