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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started