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
source share