|
using System.Collections.Generic;
using System.Text;
using Sedge.Core.Configuration;
namespace Sedge.Core.Execution.ReportElements
{
public class ReportTable : ReportElementBase
{
private IEnumerable<string> _headers;
private readonly List<IEnumerable<string>> _rows = new List<IEnumerable<string>>();
public ReportTable(Suite suite)
: base(suite)
{
}
public override void MergeWith(IReportElement element)
{
ReportTable reportTable = element as ReportTable;
if (reportTable != null)
{
foreach (IEnumerable<string> row in reportTable._rows)
{
AddRow(row);
}
}
}
public void SetHeader(IEnumerable<string> headerRow)
{
_headers = headerRow;
}
public void AddRow(IEnumerable<string> row)
{
_rows.Add(row);
}
public void AddRow(string col1, string col2)
{
_rows.Add( new[] {col1, col2} );
}
public override string GetHtml()
{
StringBuilder sb = new StringBuilder(GetHeaderAsHtml());
sb.Append("<table class=\"report-table\">");
if (_headers != null)
{
sb.Append("<tr>");
foreach (string header in _headers)
{
sb.AppendFormat("<th>{0}</th>", header);
}
sb.Append("</tr>");
}
foreach (IEnumerable<string> row in _rows)
{
sb.Append("<tr>");
foreach (string cell in row)
{
sb.AppendFormat("<td>{0}</td>", cell);
}
sb.Append("</tr>");
}
sb.Append("</table>");
return sb.ToString();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am a software developer from Toronto with 15 years of experience in software design and development. My major professional area is the development of highly customized software solutions, including desktop and web applications. Industrial process automation and hardware-related software development are among my favorite projects and I enjoyed developing several applications for semiconductor manufacturing companies.
My blog: http://LunarFrog.com/blog