好吧,我已经完成编码并且所有结果都已准备就绪,我现在需要做的就是创建 HTML 报告来显示这些结果。如何使用 C++ 创建 HTML 报告?任何想法? 如果有帮助,我正在使用 Visual Studio 来编译和运行我的代码,尽管我不太热衷于使用 VS 库,而且我更喜欢使用 C++ std 库(如果有的话)。提前谢谢你
最佳答案
一种快速的方法是将 html 标签简单地写成字符串。 这是一个例子
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();
编辑:更新代码
关于c++ - 使用 C++ 创建 HTML 报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11206604/