码迷,mamicode.com
首页 > 编程语言 > 详细

C++ 读写 Excel 文件

时间:2019-12-09 11:53:02      阅读:608      评论:0      收藏:0      [点我收藏+]

标签:需要   快速定位   namespace   har   name   std   sys   标签   sheet   

//Microsoft Visual Studio 2015 Enterprise

#include <fstream>
#include <string>
#include <iostream>
#include <streambuf>
using namespace std;
int main()
{
       //向Excel中写入数据
       ofstream oFile;
       oFile.open("scoresheet.csv", ios::out | ios::trunc); // 输出到需要的excel 文件
       oFile << "姓名" << "," << "年龄" << "," << "班级" << "," << "班主任" << endl;
       oFile << "张三" << "," << "22" << "," << "1" << "," << "JIM" << endl;
       oFile << "李四" << "," << "23" << "," << "3" << "," << "TOM" << endl;
       oFile.close();
       //读取Excel数据
       ifstream iFile("scoresheet.csv");
       string readStr((std::istreambuf_iterator<char>(iFile)), std::istreambuf_iterator<char>());
       cout << readStr.c_str();
       system("pause");
       return 0;
}


未完 ......

点击访问原文(进入后根据右侧标签,快速定位到本文)

C++ 读写 Excel 文件

标签:需要   快速定位   namespace   har   name   std   sys   标签   sheet   

原文地址:https://www.cnblogs.com/sinicheveen/p/12009817.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!