Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create HTML reports using C++

Well, I have finished coding and all my results are ready, all I need to do now is create HTML reports to display these results. How do I create HTML report using C++? any Idea? If it helps, I am using Visual Studio to compile and run my code, although I am not very keen on using VS libraries and I would prefer using C++ std libraries, if there are any. Thank you in advance

like image 470
vin Avatar asked Jun 26 '12 11:06

vin


1 Answers

A quick way to do it is simply writing the html tags as strings. Here's an example

    ofstream myfile;
    myfile.open ("C:\\report.html");
    myfile << "<!DOCTYPE html><html><head></head><body>"; //starting html

    //add some html content
    //as an example: if you have array of objects featuring the properties name & value, you can print out a new line for each property pairs like this:
    for (int i=0; i< reportData.length(); i++)
        myfile << "<p><span style='font-weight: bold'>" << reportData[i].name << "</span><span>" << reportData[i].value << "</span></p>";

   //ending html
    myfile << "</body></html>";
    myfile.close();

Edit: updated code

like image 140
Drkawashima Avatar answered Sep 27 '22 20:09

Drkawashima