using System.Text;
namespace ConsoleApp1.report
{
public class HtmlReportFormatter : IReportFormatter
{
public byte[] PrepareReport(IReportContent report)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("
");
sb.AppendLine($"{report.ReportDate}
");
foreach (var row in report.ReportRows)
{
sb.AppendLine("");
foreach (var cell in row.cells)
{
sb.AppendLine("| ");
h_Format(sb, cell);
sb.AppendLine(" | ");
}
sb.AppendLine("
");
}
sb.AppendLine("");
sb.AppendLine("");
return Encoding.UTF8.GetBytes(sb.ToString());
}
private void h_Format(StringBuilder sb, string cell)
{
sb.AppendLine(cell);
}
}
}