IEnumerableExtensionsToHtmlTableT Method
Generic approach to convert a IEnumerableT to an HTML table string representation.
Namespace: DevCase.Extensions.IEnumerableExtensionsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public static string ToHtmlTable<T>(
this IEnumerable<T> enumerable,
string tableStyle = "",
string headerStyle = "",
string rowStyle = "",
string alternateRowStyle = ""
)
<ExtensionAttribute>
Public Shared Function ToHtmlTable(Of T) (
enumerable As IEnumerable(Of T),
Optional tableStyle As String = "",
Optional headerStyle As String = "",
Optional rowStyle As String = "",
Optional alternateRowStyle As String = ""
) As String
Dim enumerable As IEnumerable(Of T)
Dim tableStyle As String
Dim headerStyle As String
Dim rowStyle As String
Dim alternateRowStyle As String
Dim returnValue As String
returnValue = enumerable.ToHtmlTable(tableStyle,
headerStyle, rowStyle, alternateRowStyle)
public:
[ExtensionAttribute]
generic<typename T>
static String^ ToHtmlTable(
IEnumerable<T>^ enumerable,
String^ tableStyle = L"",
String^ headerStyle = L"",
String^ rowStyle = L"",
String^ alternateRowStyle = L""
)
[<ExtensionAttribute>]
static member ToHtmlTable :
enumerable : IEnumerable<'T> *
?tableStyle : string *
?headerStyle : string *
?rowStyle : string *
?alternateRowStyle : string
(* Defaults:
let _tableStyle = defaultArg tableStyle ""
let _headerStyle = defaultArg headerStyle ""
let _rowStyle = defaultArg rowStyle ""
let _alternateRowStyle = defaultArg alternateRowStyle ""
*)
-> string
No code example is currently available or this language may not be supported.
- enumerable IEnumerableT
-
The collection of objects to be converted.
- tableStyle String (Optional)
-
Optional. The CSS class name or style to be applied to the table element.
- headerStyle String (Optional)
-
Optional. The CSS class name or style to be applied to the header cells (th) of the table.
- rowStyle String (Optional)
-
Optional. The CSS class name or style to be applied to the data cells (td) of the table rows.
- alternateRowStyle String (Optional)
-
Optional. The CSS class name or style to be applied to the alternate data rows of the table.
- T
-
The type of the objects in the source collection.
String
A HTML table string representation of the source
IEnumerableT.
In Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerableT. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
This is a code example.
No code example is currently available or this language may not be supported.
Public Class Person
Public Property FirstName() As String
Public Property LastName() As String
Public Property Age() As Integer
End Class
Dim personList As New List(Of Person)()
personList.Add(New Person With {
.FirstName = "Alex",
.LastName = "Friedman",
.Age = 27
})
personList.Add(New Person With {
.FirstName = "Jack",
.LastName = "Bauer",
.Age = 45
})
personList.Add(New Person With {
.FirstName = "Cloe",
.LastName = "O'Brien",
.Age = 35
})
personList.Add(New Person With {
.FirstName = "John",
.LastName = "Doe",
.Age = 30
})
Dim cssStyle As String =
"<style type = ""text/css"">
.tableStyle { border: solid 5 green; }
th.header { background-color:#FF3300 }
tr.rowStyle { background-color:#33FFFF; border: solid 1 black; }
tr.alternate { background-color:#99FF66; border: solid 1 black; }
</style>"
Dim htmlTable As String = personList.ToHtmlTable("tableStyle", "header", "rowStyle", "alternate")
Dim finalHtml As String = cssStyle & htmlTable
Console.WriteLine(finalHtml)
File.WriteAllText($".\{NameOf(personList)}.html", finalHtml)
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.