'Creates a html text that displays the data in a table.
'The style of the table can be changed by modifying HtmlCSS variable.
'The TextSize parameter allows to change the text size, standard is 16
Sub ExecuteHtml2(SQL As SQL, Query As String, StringArgs() As String, Limit As Int, Clickable As Boolean, TextSize As Int) As String
Dim Table As List
Dim cur As Cursor
Dim HtmlCSS2 As String
HtmlCSS2 = "table {width: 100%;border: 1px solid #cef;text-align: left; }" _
& " th { font-size:" & TextSize & "px; font-weight: bold; background-color: #acf; border-bottom: 1px solid #cef; }" _
& "td,th { padding: 4px 5px; }" _
& ".odd {background-color: #def; } .odd td {border-bottom: 1px solid #cef; }" _
& "a { font-size:" & TextSize & "px; text-decoration:none; color: #000;}"
If StringArgs <> Null Then
cur = SQL.ExecQuery2(Query, StringArgs)
Else
cur = SQL.ExecQuery(Query)
End If
Log("ExecuteHtml: " & Query)
If Limit > 0 Then Limit = Min(Limit, cur.RowCount) Else Limit = cur.RowCount
Dim sb As StringBuilder
sb.Initialize
sb.Append("<html><body>").Append(CRLF)
sb.Append("<style type='text/css'>").Append(HtmlCSS2).Append("</style>").Append(CRLF)
sb.Append("<table><tr>").Append(CRLF)
For i = 0 To cur.ColumnCount - 1
sb.Append("<th>").Append(cur.GetColumnName(i)).Append("</th>")
Next
sb.Append("</tr>").Append(CRLF)
For row = 0 To Limit - 1
cur.Position = row
If row Mod 2 = 0 Then
sb.Append("<tr>")
Else
sb.Append("<tr class='odd'>")
End If
For i = 0 To cur.ColumnCount - 1
sb.Append("<td>")
If Clickable Then
sb.Append("<a href='http://").Append(i).Append(".")
sb.Append(row)
sb.Append(".com'>").Append(cur.GetString2(i)).Append("</a>")
Else
sb.Append(cur.GetString2(i))
End If
sb.Append("</td>")
Next
sb.Append("</tr>").Append(CRLF)
Next
cur.Close
sb.Append("</table></body></html>")
Return sb.ToString
End Sub