[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 309
  • Last Modified:

How can I custom format an html page that has been exported from a VB6 msflexgrid?

I found the following code (below) here on EE that allows me to send msflexgrid data to an html page. The code works fine in my VB6 program.....

Question:  
How can I custom format the html so that I can show gridlines, customize backcolor, change font color etc.

Public Sub gridToHtml()
Dim iFree As Long
iFree = FreeFile
Open "report.html" For Output As #iFree
Print #iFree, "<html><head></head><body><table>"
With MSFlexGrid1
For I = 0 To .Rows - 1
    Print #iFree, "<tr>"
    For J = 0 To .Cols - 1
        Print #iFree, "<td>" & .TextMatrix(I, J) & "</td>"
    Next
    Print #iFree, "</tr>"
Next
Print #iFree, "</table></body><html>"
Close #iFree
End With
End Sub
0
jazjef
Asked:
jazjef
  • 2
  • 2
1 Solution
 
d3nCommented:
Fastest way to do this is inserting HTML markup in the strings.

For gridlines: Print #iFree, "<html><head></head><body><table border=1>"

For font color:         Print #iFree, "<td><font color=#FF0000>" & .TextMatrix(I, J) & "</font></td>"

Better way is using CSS...
0
 
jazjefAuthor Commented:
any other suggestions?..... I am having a difficult time formatting the data this way. The html seems to be buggy when used this way. How does one integrate CSS?
0
 
d3nCommented:
You can integrate CSS inline or with a separate .css file

In header section of your HTML, link to the .css file, you'll get something like this:
Print #iFree, "<html><head><link rel="stylesheet" href="stylesheet.css" type="text/css"></head><body><table>"

Open in new window


you can place a reference to the appropriate class in each html-tag like this:
Print #iFree, "<td class=TableCell>" & .TextMatrix(I, J) & "</td>"

Open in new window


Your CSS file will look like this:
.TableCell
{
	color: #FFFFFF;
	background-color:#000000;
}

Open in new window





0
 
jazjefAuthor Commented:
Thanks d3n... I was able to learn how to create a nice basic html report with your code from your first post; I can see how the style sheet thing would probably be better----but I think I'll make that a separate question in the near future.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now