Rette exceludtræk til
Jeg bruger nedenstående til at danne et excelark udfra min accessbase. Men jeg vil gerne have et fortløbende nummer i første kolonne.1 stregkode tid
2 stregkode tid
3 stregkode tid
Nogle der kan finde ud af at add'e det til nedenstående script?
<%
Dim objConn 'Holds the Database Connection Object
Set objConn = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\inetpub\wwwroot\stafet.mdb"
Function CreateExcel(Title,tblname)
Dim Rs,Fso,Act,fname
Fname = "Udtrak_hold_tid.xls"
Set rs = Server.CreateObject("ADODB.Recordset")
Set FSO = Createobject("scripting.filesystemobject")
Set act = Fso.CreateTextfile(server.mappath(Fname),true)
rs.Open Tblname, objconn, 3, 3
If Not Rs.EOF and not Rs.BOF Then
act.WriteLine "<html xmlns:x=""urn:schemas-microsoft-com:office:excel"">"
act.WriteLine "<head>"
act.WriteLine "<!--[if gte mso 9]><xml>"
act.WriteLine "<x:ExcelWorkbook>"
act.WriteLine "<x:ExcelWorksheets>"
act.WriteLine "<x:ExcelWorksheet>"
act.WriteLine "<x:Name>"& title &"</x:Name>"
act.WriteLine "<x:WorksheetOptions>"
act.WriteLine "<x:Print>"
act.WriteLine "<x:ValidPrinterInfo/>"
act.WriteLine "</x:Print>"
act.WriteLine "</x:WorksheetOptions>"
act.WriteLine "</x:ExcelWorksheet>"
act.WriteLine "</x:ExcelWorksheets>"
act.WriteLine "</x:ExcelWorkbook>"
act.WriteLine "</xml>"
act.WriteLine "<![endif]--> "
act.WriteLine "</head>"
act.WriteLine "<body>"
Act.Writeline "<table border=1>"
Act.Writeline "<Tr>"
For X = 0 to Rs.Fields.count - 1
Act.Writeline "<Td><b>" & Rs.Fields.Item(x).Name & "</b></td>"
Next
Act.Writeline "</Tr>"
While not Rs.Eof
Act.Writeline "<Tr>"
For X = 0 To Rs.Fields.Count - 1
Act.Writeline "<Td>" & Rs.Fields.Item(X).Value & "</td>"
Next
Act.Writeline "</Tr>"
Rs.Movenext
Wend
Act.Writeline "</Table>"
act.writeline "<tr></tr>"
act.writeline "<tr>BEC Stafet 2010</tr>"
act.WriteLine "</body>"
act.WriteLine "</html>"
End if
Act.close
Rs.close
%>
<html>
<body style="background-color: #ECF9FF">
Dit excel udtræk kan hentes hér: <a href="<%=fname%>" target="_blank"> Udtræk </a>
<br>
<br>
<a href="index.asp" target="_self"> Tilbage </a>
</body>
</html>
<%
End function
call CreateExcel("Holdenes tider","SELECT stregkode, tid FROM scanning WHERE RIGHT(stregkode, 2) = 'p3' order by tid asc")
'Reset server objects
Set rs = Nothing
Set objConn = Nothing
%>
