morgancaroline
Programmer
I have written an asp which queries a database but instead of writing the results in a html table, I want to write them in an existing excel worksheet (a template) using code such as
Set cn = Server.CreateObject("ADODB.Connection"
Set rs = Server.CreateObject("ADODB.Recordset"
cn.Open "DSN=zdev_dep;uid=sa;pwd=sa;"
rs.CursorLocation = adUseClient
rs.CursorType = adOpenStatic
rs.ActiveConnection = cn
Dim RowCnt, FieldCnt
RowCnt = 2
FieldCnt = 3
Cells(RowCnt, FieldCnt).Value = "Department"
' Fill rows with records, starting at row 2.
Count = 0
Do While Not rs.EOF
RowCnt = Count + 9
Cells(RowCnt, 1).Value = 9988
For FieldCnt = 1 To 6
Cells(RowCnt, FieldCnt + 1).Value = rs.Fields(FieldCnt)
Next FieldCnt
Count = Count + 1
rs.MoveNext
loop
rs.Close
cn.Close
Does anyone know how I tell the computer I'm refering to the cells of an existing excel worksheet?
thanks
Set cn = Server.CreateObject("ADODB.Connection"
Set rs = Server.CreateObject("ADODB.Recordset"
cn.Open "DSN=zdev_dep;uid=sa;pwd=sa;"
rs.CursorLocation = adUseClient
rs.CursorType = adOpenStatic
rs.ActiveConnection = cn
Dim RowCnt, FieldCnt
RowCnt = 2
FieldCnt = 3
Cells(RowCnt, FieldCnt).Value = "Department"
' Fill rows with records, starting at row 2.
Count = 0
Do While Not rs.EOF
RowCnt = Count + 9
Cells(RowCnt, 1).Value = 9988
For FieldCnt = 1 To 6
Cells(RowCnt, FieldCnt + 1).Value = rs.Fields(FieldCnt)
Next FieldCnt
Count = Count + 1
rs.MoveNext
loop
rs.Close
cn.Close
Does anyone know how I tell the computer I'm refering to the cells of an existing excel worksheet?
thanks