You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1023 B

10 months ago
using System.Text;
namespace ConsoleApp1.report
{
public class HtmlReportFormatter : IReportFormatter
{
public byte[] PrepareReport(IReportContent report)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("<HTML><BODY>");
sb.AppendLine($"<H1>{report.ReportDate}</H1");
sb.AppendLine("<TABLE>");
foreach (var row in report.ReportRows)
{
sb.AppendLine("<TR>");
foreach (var cell in row.cells)
{
sb.AppendLine("<TD>");
h_Format(sb, cell);
sb.AppendLine("</TD>");
}
sb.AppendLine("</TR>");
}
sb.AppendLine("</TABLE>");
sb.AppendLine("</BODY></HTML>");
return Encoding.UTF8.GetBytes(sb.ToString());
}
private void h_Format(StringBuilder sb, string cell)
{
sb.AppendLine(cell);
}
}
}