smalloy
Posts: 107
|
| Posted: 12/02/2004, 10:24 AM |
|
I hate to beat a dead horse but I can't get my code to work, I get to the point where a dialog box opens with the standard "Do you want to Open or Save ..." If you choose either you get this error:
Could Not Open (or Internet Explorer could not download)
'http://myserver/Excel.asp?s_Date_Add_Recorded=10/1/04&s_Date_Drop_Recorded=12/2/04'
Then:
Microsoft Office can not access the file 'http://myserver/Excel.asp?s_FromDate=10/1/04' ...
Here is my code, its in the AfterInitialize portion of the page. Another page calls this one with the s_FromDate as its parameter:
Function Page_AfterInitialize() 'Page_AfterInitialize @1-1E3DE16C
'Custom Code @2-73254650
' -------------------------
'This is to export to Excel
Dim DBPattersonAuto
Dim sSQL
Dim sWhere
Dim objrs
Dim i
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader"Content-Disposition", "attachment;filename=""Report.xls"""
If CCGetParam("s_Date_Add_Recorded","") <> "" Then
sWhere = " Where ([Date Add Recorded] >= s_Date_Add_Recorded) And "
sWhere = sWhere & " ([Date Add Recorded] <= s_Date_Drop_Recorded) Or "
sWhere = sWhere & " ([Date Drop Recorded] >= s_Date_Add_Recorded) And "
sWhere = sWhere & " ([Date Drop Recorded] <= s_Date_Drop_Recorded) "
End IF
Set DBPattersonAuto = New clsDBPattersonAuto
sSQL = "* FROM Autos "
sSQL = sSQL & sWhere & " order by [Sequential Change No] "
set objrs=DBPattersonAuto.Execute(sSQL)
Response.Write("<TABLE BORDER=1>")
Response.Write("<TR>")
' Loop through each Field, printing out the Field Names
For i = 0 to objrs.fields.count - 1
Response.Write("<TD>" & objrs(i).name & "</TD>")
Next
Response.Write("</TR>")
' Loop through rows, displaying each field
While not (objrs.EOF or objrs.BOF)
Response.Write("<TR>")
For i = 0 to objrs.fields.count - 1
Response.Write("<TD VALIGN=TOP>" & objrs(i) & "</TD>")
Next
Response.Write("</TR>")
objrs.MoveNext
Wend
objrs.Close
' -------------------------
'End Custom Code
End Function 'Close Page_AfterInitialize @1-54C34B28
I am so close I can feel it! Any help much appreciated!
_________________
Anything can be done, just give me time and money. |
 |
 |
smalloy
Posts: 107
|
| Posted: 12/02/2004, 10:33 AM |
|
FYI I cut the Select statement down significantly - I just cut the Select out by accident when I deleted the very long code"
Thanks!
_________________
Anything can be done, just give me time and money. |
 |
 |
GeorgeS
Posts: 206
|
| Posted: 12/02/2004, 1:46 PM |
|
I'm using a page with simple grid (no headers/sorters & navigation).
the only custom code is this:
Function Page_AfterInitialize() 'Page_AfterInitialize @1-1E3DE16C
'Custom Code @17-73254650
' -------------------------
' Write your own code here.
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
' -------------------------
'End Custom Code
End Function 'Close Page_AfterInitialize @1-54C34B28
Exports to Excel just fine...
_________________
GeorgeS |
 |
 |
smalloy
Posts: 107
|
| Posted: 12/02/2004, 1:57 PM |
|
You saved the day!! Lots and lots of un-necessary code. I figured I would buid the table with ASP and then generate the XL sheet.
Thank you George!!!!!!!
_________________
Anything can be done, just give me time and money. |
 |
 |
TonyR
|
| Posted: 12/08/2004, 5:47 AM |
|
Thanks for this - its just what I was looking for :)
It took me a while before I realized that the 'after initialize' function was an event - after finding it and realising..... I now feel a bit silly for not knowing 
Thanks Again
|
|
|
 |
|