public static string ToHtmlTableText(this DataTable table) { var tableElem = new HtmlElem("table"); // tr for the column heading of each column of the report. { var trElem = tableElem.AddElem("tr"); // <th> for each column. for( int ix = 0; ix < table.Columns.Count; ++ix) { var col = table.Columns[ix]; var thElem = trElem.AddText("th", col.ColumnName); } } // <tr> for each row of the report. for( int ix = 0; ix < table.Rows.Count; ++ix) { var row = table.Rows[ix]; var trElem = tableElem.AddElem("tr"); // td for each data item of the row. for( int jx = 0; jx < table.Columns.Count; ++jx) { var tdElem = trElem.AddText("td", row[jx].ToString( )); } } var tableText = tableElem.ToString(); return tableText; }
public string ToHtmlTableText( ) { var tableElem = new HtmlElem("table"); // tr for the column heading of each column of the report. { var trElem = tableElem.AddElem("tr"); // <th> for each column. foreach (var column in this.Columns) { var thElem = trElem.AddText("th", column.ColName); } } // <tr> for each row of the report. foreach (var row in this.Rows) { var trElem = tableElem.AddElem("tr"); // td for each data item of the row. foreach (var dataItem in row) { var tdElem = trElem.AddText("td", dataItem.Value); } } var tableText = tableElem.ToString(); return(tableText); }