Dim xlsFile, filePath, strPage
Const ForWriting = 2
xlsFile = "monplaning.xls"
filePath = Replace(WScript.ScriptFullName, WScript.ScriptName, "" )
Set conn = Wscript.CreateObject("ADODB.Connection" )
Set rs = Wscript.CreateObject("ADODB.Recordset" )
str = "Driver={Microsoft Excel Driver (*.xls)}; DBQ=" & filePath & xlsFile
conn.Open str
sNameSheet = "Feuil1"
sCells = "A1:H3"
SQL = "SELECT * from `" & sNameSheet & "$" & sCells & "`"
rs.Open SQL, conn
strPage = "<html>" & vbCrLf & _
" <head>" & vbCrLf & _
" <title>Planing 2010</title>" & vbCrLf & _
" <style type=""text/css"">" & vbCrLf & _
" table { border: 1px solid black; border-collapse:collapse; }" & vbCrLf & _
" td { border: 1px solid black; width: 30px; text-align: center; }" & vbCrLf & _
" </style>" & vbCrLf & _
" </head>" & vbCrLf & _
" <body>" & vbCrLf & _
" <table>" & vbCrLf
do while not rs.eof
strPage = strPage & " <tr>" & vbCrLf
for each field in rs.fields
If IsNull(field.value) Then
strPage = strPage & " <td></td>" & vbCrLf
Else
strPage = strPage & " <td>" & field & "</td>" & vbCrLf
End If
next
strPage = strPage & " </tr>" & vbCrLf
rs.moveNext()
loop
strPage = strPage & " </table>" & vbCrLf
strPage = strPage & " </body>" & vbCrLf
strPage = strPage & "</html>" & vbCrLf
Set fso = CreateObject("Scripting.FileSystemObject" )
Set f = fso.OpenTextFile(PATH & "index.html", ForWriting, true)
f.write(strPage)
rs.close
conn.close
f.close
set rs=nothing
set conn=nothing |