' cvt en html sauf ligatures e
function cvhtml(a)
dim s
s = a
s = replace(s, "&", "&")
s = replace(replace(s, ">", ">"), "<", "<")
s = replace(replace(replace(s, "Ä", "Ä"), "Â", "Â"), "À", "À")
s = replace(replace(replace(s, "ä", "ä"), "â", "â"), "à", "à")
s = replace(replace(replace(replace(s, "Ë", "Ë"), "Ê", "Ê"), "È", "È"), "É", "É")
s = replace(replace(replace(replace(s, "ë", "ë"), "ê", "ê"), "è", "è"), "é", "é")
s = replace(replace(replace(replace(s, "ï", "ï"), "î", "î"), "Ï", "Ï"), "Î", "Î")
s = replace(replace(replace(s, "Ö", "Ö"), "Ô", "Ô"), "Ó", "Ó")
s = replace(replace(replace(s, "ö", "ö"), "ô", "ô"), "ó", "ó")
s = replace(replace(replace(replace(s, "Ü", "Ü"), "Û", "Û"), "Ú", "Ú"), "Ù", "Ù")
s = replace(replace(replace(replace(s, "ü", "ü"), "û", "û"), "ú", "ú"), "ù", "ù")
s = replace(replace(s, "ç", "ç"), "Ç", "Ç")
cvhtml = s
end function
function htmlHead(aTitre)
dim s
s = "<html><head>"
if trim(aTitre) <> "" then s = s & "<Title>" & cvhtml(aTitre) & "</Title>"
HtmlHead = s & vbCRLF & "<style type=""text/css"" media=""screen"">td, th {font-size:75%;}</style>" & vbCRLF
end function
function HtmlHeadToBody(aAttribs)
if trim(aAttribs) = "" then
htmlHeadToBody = "</head><body>" & vbCRLF
else
htmlHeadToBody = "</head><body " & aAttribs & ">" & vbCRLF
end if
end function
function HtmlFoot
HtmlFoot = "<br><font size=""-1"">" & cvhtml("Page générée le " & date & " à " & time) & "</font><br></body></html>" & vbCRLF
end function
function HtmlTableHeader(aRecordSet)
dim s, i
s = "<tr>"
for i = 0 to aRecordset.Fields.count - 1
s = s & tagTH(cvhtml(aRecordset.fields(i).Name) & "<!-- type:" & aRecordset.fields(i).Type & " -->")
next
HtmlTableHeader = s & "</tr>" & vbCRLF
end function
function HtmlTableLine(aRecordSet)
dim s, i, t
s = "<tr>"
for i = 0 to aRecordSet.Fields.Count - 1
t = aRecordSet.fields(i).Type
if (t = 3) or (t = 131) then
s = s & gTag("td", "align=""right""", nbspifnull(cvhtml(trim(aRecordSet.fields(i) & " "))))
else
s = s & tagTD(cvhtml(trim(aRecordSet.fields(i) & " ")))
end if
next
HtmlTableLine = s & "</tr>" & vbCRLF
end function
function nbspIfNull(s)
if s = "" then nbspIfNull = " " else nbspIfNull = s
end function
function gTag(tag, attribs, s)
if trim(attribs) = "" then gTag = "<" & tag & ">" & s & "</" & tag & ">" else gTag = "<" & tag & " " & attribs & ">" & s & "</" & tag & ">"
end function
function TagTH(s)
if s = "" then TagTH = "<th> </th>" else tagTH = "<th>" & s & "</th>"
end function
function TagTD(s)
if s = "" then TagTD = "<td> </td>" else tagTD = "<td>" & s & "</td>"
end function
function TagTR(s)
tagTR = gTag("tr", "", s)
end function
function tagH3(s)
tagH3 = gTag("h3", "", s)
end function
sub htmlCursorToFile(aRecordset, aFilename, aTitle)
dim lFSO
dim fout
set lFSO = CreateObject("Scripting.FileSystemObject")
set fout = lFSO.OpenTextFile(aFilename, 2, true)
fout.WriteLine htmlHead(aTitle)
fout.WriteLine htmlHeadToBody("")
fout.WriteLine "<table border>"
fout.WriteLine htmlTableHeader(aRecordset)
do while not aRecordset.EOF
fout.WriteLine htmlTableLine(aRecordset)
aRecordset.Movenext
loop
fout.WriteLine "</table>" & htmlFoot
fout.Close
set fout = nothing
set lFSO = nothing
end sub
lundi 27 octobre 2008
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire