1 reply
by paul.graf
You could have the user submit a query and present them with choice of outputting to HTML table or to Excel. THe following include file outputs a resultset to an Excel sheet:
<%
'-----------------------------------------------
' Build Excel CSV file.
' NOTE: ASSUMES AT LEAST ONE RECORD IN RECORDSET
'-----------------------------------------------
Sub outputExcel
dim lIndex
dim hIndex
dim Cnt
dim excelHeader
dim excelRow
lIndex = LBound(displayFields)
hIndex = UBound(displayFields)
Response.ContentType = "application/vnd.ms-excel"
'Response.ContentType = "application/x-tsv"
' Now build column header
excelHeader = ""
For Cnt = lIndex to hIndex
If Cnt < hIndex Then
excelHeader = excelHeader & displayHeaders(Cnt) & vbTab
Else
excelHeader = excelHeader & displayHeaders(Cnt) & vbCrLf
End If
Next
Response.Write excelHeader
' Finally, output the data.
Do While Not objRecSet.EOF
excelRow = ""
For Cnt = lIndex to hIndex Select Case displayFields(Cnt)
Case "ARCHIVE_DATE"
excelRow = excelRow & OracleDate(objRecSet(displayFields(Cnt)))
'"DOC_DATE" will be included above when it is an actual date
Case Else
excelRow= excelRow & objRecSet(displayFields(Cnt))
End Select
If Cnt < hIndex Then
excelRow = excelRow & vbTab
Else
excelRow = excelRow & vbCrLf
End If
Next
Response.Write excelRow
objRecSet.MoveNext
Loop
objRecSet.Close
End Sub
%>
Hope this helps!
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending