### Export TableView to HTML

Export the content of a tableview to HTML file.
The html table is formatted using CSS Style.
The html file is shown in the default browser. Requires the standard jFX library.
' Export content of a tableview to html file
' Parameter Tableview
' Parameter Folder HTML file is stored
' Parameter HTML filename
`Sub tableviewExportHTML(tv As TableView, foldername As String, filename As String)
Dim css As String = "" & _
"body { Font-size: 1.1em; Font-family:'Times New Roman,Times,serif'; color:blue; }" & _
"h1 { color:red; Font-size:2.0em; }" & _
"p { color:gray; Font-size:0.8em; }" & _
"table.gridtable {Font-family: verdana,arial,sans-serif;Font-size:11px;color:#333333;border-width: 1px;border-color: #666666;border-collapse: collapse;}" & _
"table.gridtable th {border-width: 1px;padding: 8px;border-style: solid;border-color: #666666;background-color: #dedede;}" & _
"table.gridtable td {border-width: 1px;padding: 8px;border-style: solid;border-color: #666666;background-color: #ffffff;}" & _
"hr { border:solid #ff0000 1px;height:1px; }" & _
""
Dim tw As TextWriter ' textfile to write
Dim l As List ' List to store html code
l.Initialize
l.Add("
" & css & "
")
l.Add("")
' Heading
Dim w As Double
l.Add("
")
For i = 0 To tv.ColumnsCount - 1
w = (tv.GetColumnWidth(i) / tv.Width) * 100
l.Add("" & tv.GetColumnHeader(i) & "")
Next
l.Add("
")
' Data
For i = 0 To tv.Items.Size - 1
l.Add("
")
tv.SelectedRow = i
Dim Row() As Object = tv.SelectedRowValues
For j = 0 To Row.Length - 1
w = (tv.GetColumnWidth(j) / tv.Width) * 100
l.Add("" & Row(j) & "")
Next
l.Add("
")
Next
l.Add("

Created " & DateTime.Date(DateTime.Now) & " :: File: " & filename & "

")
Try
tw.Initialize(File.OpenOutput(foldername, filename, False))
tw.WriteList(l)
tw.Flush
tw.Close
fx.ShowExternalDocument(File.GetUri(foldername, filename))
Catch
Log("Error exporting HTML file: " & LastException.Message)
If tw.IsInitialized Then tw.Close
End Try
End Sub`

Changed: , Category: TableView, File: T6C259M1882.htm, ID: 1882