Reputation: 117
I have created a program that merges files and I have decided to output the results as an HTML document so that it is legible. I have achieved this output using System.IO.StreamWriter and creating a textfile with all the html formatting and in-line CSS and saving it with the .html extension like so:
Dim lstrBackupOutput = "Test.html"
Dim lobjWriter As New System.IO.StreamWriter(lstrBackupOutput)
Dim lobjWriter as
lobjWriter.WriteLine("<html>")
lobjWriter.WriteLine("</head>")
lobjWriter.WriteLine("<style type=""text/css""> h1,h2,h3{font-family:Arial, Serif;} table{border-collapse:collapse; width:100%; font-family:Arial,Helvetica,Sans-serif;} th{height:30px;} td{text-align:left; padding:7px;} table, th, td{border:1px solid green;} </style>")
lobjWriter.WriteLine("</head>")
etc.
Is there more of a VB.NET way to do this? Most of my searches churn out ASP.NET results that don't seem to apply.
Thanks.
Upvotes: 2
Views: 11111
Reputation: 857
I would use XSLT for this approach 9 times out of 10.
It depends on how much dynamic data you need to have in the HTML. If it's a good amount, or you need repeating rows of data, then XSLT is the way to go.
Here's a good start if you are unfamiliar with XSLT: XSLT Tutorial (W3Schools)
Upvotes: 1
Reputation: 811
check out this article http://cdmckay.org/blog/2009/02/01/creating-an-html-document-with-net/
The XML approach is a good start...
' Create the body element and append it to the root.
Dim xmlBody As XmlElement = xmlDoc.CreateElement("body")
xmlRoot.AppendChild(xmlBody)
Upvotes: 1