Public Sub SaveHTMLTabletoFile()
Try
Dim sb As StringBuilder = New StringBuilder()
sb.Clear()
sb.AppendLine("<table id='tbl1' border='0'>")
sb.AppendLine("<tr>")
sb.AppendLine("<td>Test 1</td>")
sb.AppendLine("</tr>")
sb.AppendLine("<tr>")
sb.AppendLine("<td>Test 2</td>")
sb.AppendLine("</tr>")
sb.AppendLine("</table>")
Dim path As String = Server.MapPath("download")
If Not Directory.Exists(path) Then
Directory.CreateDirectory(path)
End If
Dim strPath As String = Server.MapPath("download/test.html")
Dim fStream As FileStream = File.Create(strPath)
fStream.Close()
Dim sWriter As New StreamWriter(strPath)
sWriter.Write(sb)
sWriter.Close()
Catch ex As Exception
Console.Write(ex.Message)
End Try
End Sub
Try
Dim sb As StringBuilder = New StringBuilder()
sb.Clear()
sb.AppendLine("<table id='tbl1' border='0'>")
sb.AppendLine("<tr>")
sb.AppendLine("<td>Test 1</td>")
sb.AppendLine("</tr>")
sb.AppendLine("<tr>")
sb.AppendLine("<td>Test 2</td>")
sb.AppendLine("</tr>")
sb.AppendLine("</table>")
Dim path As String = Server.MapPath("download")
If Not Directory.Exists(path) Then
Directory.CreateDirectory(path)
End If
Dim strPath As String = Server.MapPath("download/test.html")
Dim fStream As FileStream = File.Create(strPath)
fStream.Close()
Dim sWriter As New StreamWriter(strPath)
sWriter.Write(sb)
sWriter.Close()
Catch ex As Exception
Console.Write(ex.Message)
End Try
End Sub
No comments:
Post a Comment