Question: Hi, I need to create a c++ program but I do not know how to begin. It needs to output the information as a .xls

Hi, I need to create a c++ program but I do not know how to begin. It needs to output the information as a .xls file (excel file) not .csv with a header row with heading for each column and a data row with one set of data. Also, I need to include at least 3 columns of information with real or made up data. Most important it needs to be a .xls file not .csv since the requeriments says and I can only output a .xls file. The program needs to output the .xls file. Thanks.

#include

#include

using namespace std;

struct student

{

string name;

int id;

double average;

};

int main()

{

string filename = "data.xls";

//create 3 students using the structure array

student s[3] = { { "John", 111, 75.5 },

{ "Alice", 222, 90.0 },

{ "Bob", 333, 87.6 } };

ofstream outFile(filename.c_str());

outFile << "Name,ID,Average" << endl; //column headings

//print the comma separated data rows

for (int i = 0; i < 3; i++)

{

outFile << s[i].name << "," << s[i].id << "," << s[i].average << endl;

}

outFile.close();

cout << "Please open " << filename << " in Excel" << endl;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!