Creating HTML reports using C ++

Well, I finished coding, and all my results are ready, all I have to do is create HTML reports to display these results. How to create an HTML report using C ++? Any ideas? If this helps, I use Visual Studio to compile and run my code, although I do not really like to use VS libraries, and I would prefer to use std ++ libraries, if any. Thank you in advance

+6
source share
3 answers

A quick way to do this is to simply write the html tags as strings. Here is 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

+2
source

Well, HTML is text, so all the regular tools from write to std::ostream fully capable of displaying output to you. I would suggest that you simply generate XML that describes the hierarchy of the data structure, and then apply scripts, style sheets, or something else to format them to your liking.

0
source

What you may need is the C ++ HTML Template Engine. You can find the list here.

0
source

Source: https://habr.com/ru/post/919023/


All Articles