C++ 读写 Excel 文件

//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;
}


未完 ......

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

猜你喜欢

转载自www.cnblogs.com/sinicheveen/p/12009817.html