1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| <%
name = "commande_MODELE" & ".xls"
path = "C:\Documents and Settings\boss_gama\Mes documents\excel\"
docname = replace(date,"/","") & replace(Time,":","") & ".xls"
Set fs = Server.CreateObject("Scripting.FileSystemObject")
file = path & name
fs.CopyFile path & "\tmp\" & docname, file
file = path & "\tmp\" & docname
'--- Modifier le fichier excel
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & file & _
";Extended Properties=""Excel 8.0;HDR=YES;"""
strSheet= "Feuil1"
Set oRS = Server.CreateObject("ADODB.Recordset")
oRS.Open "SELECT * FROM " & strSheet, oConn, adOpenKeyset, adLockOptimistic
'Nous récupérons les données contenues dans la table mysql
sql = "SELECT " & request.form("Champ") & " FROM " & request.form("Table") & " WHERE " & request.form("id") & " = " & request.form("num")
response.write sql
rst.open SQL ,conn
Do Until oRS.EOF
if not rst.eof then
For i = 0 To rst.Fields.Count - 1 ' on parcours tous les champs
Cells.Replace What = rst.Fields(i), Replacement = rst.Fields(i).value, LookAt = xlPart, _
SearchOrder = xlByRows, MatchCase = False, SearchFormat = False, _
ReplaceFormat = False
next
end if
loop
oRS.close
oConn.Close
fs.CopyFile path & "\templates\" & docname & ".xls", file
fs.DeleteFile file
Set oConn = Nothing
%> |
Partager