CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 ASP export to Excel (CSV) - Can't find excel file?

Print topic Send  topic

Author Message
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.
View profile  Send private message
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.
View profile  Send private message
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
View profile  Send private message
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.
View profile  Send private message
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 :-D

Thanks Again

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.