写入excel


写入excel的代码,做个备份:

//#include"stdafx.h"
#include 
#include
#include
//以下是文件读入输出需要的头文件
#include
#include
#include
#include <string>
using namespace std;
const int maxn = 30;
int i, j;

struct node
{
    long number;
    char name;
    int score;
    int sum;
};

void write_to_excel(bool& flag, node& pp)
{
    ofstream opt;
    opt.open("C++输出文档最新版.csv", ios::out|ios::trunc);
    opt << "学号" << "," << "姓名" << "," << "A科成绩" << ","<<"int" << endl;
    for (i = 0; i < maxn; i++)
        opt << pp.number << "," << pp.name << "," << pp.score << "," < endl;
    opt.close();
    flag = 1;
}

int main()
{
    node pp;
    pp.name = '3';
    pp.number = 45;
    pp.score = 23;
    pp.sum = 90;

    bool flag;
    write_to_excel(flag, pp);//写进表的函数
    return 0;
}

/*
#include
#include
using namespace std;

struct Mach
{
    string a="a1";
};

struct BellMach :public Mach
{
    string a="a2";
    string b = "b2";
};

bool allocate(Mach mach){
    cout << mach.a<<"a" << endl;
    return true;
};


bool allocate(BellMach mach) {
    cout << mach.a <<"b"<< endl;
    return true;
};

int main()
{
    vector mv;
    Mach *mac1 = new Mach;
    mv.push_back(mac1);
    BellMach*bmac = new BellMach;
    mv.push_back(bmac);
    Mach* bmac1 = mv[1];
    cout << bmac1->a << "a" << endl;
    BellMach* bmac2 = static_cast(bmac1);
    cout << bmac2->a << "b" << endl;
    cout << bmac2->b << "b" << endl;
    return 0;
}

*/