C
CJM
[Apologies for previous half-post: I regularly mistype some kind of key
combo that submits the post]
I have a page on our intranet that is supposed to stream an Excel sheet to
the user. I'm using pretty standard code:
sFilePath = sFileDir & sFilename
Response.AddHeader "content-disposition","attachment; filename=" & sFilePath
' Create your header information
Response.ContentType = "application/x-msexcel"
' Create and configure your object
Set oFStream = Server.CreateObject("ADODB.Stream")
oFStream.Open
oFStream.Type = 1
oFStream.LoadFromFile(sFilePath)
' Stream it to the client
Response.BinaryWrite oFStream.Read
' Cleanup
oFStream.Close
Set oFStream = Nothing
' force the end
Response.End
This works fine on the main server, but not on my development machine (XP
Pro x64). This has all worded in the past, but this is a new machine, and I
can't get it to work since I've moved across. I'm getting a 'File could not
be opened' error message. In the past, I've had this error when I wasn't
pointing at the right place or where the permissions were not configured
correctly.
Currently the IUSR user has R/W access to the whole folder where the XLS
file is (It's actually in the same folder as the ASP page at them moment).
I've also checked that the filename and path are correct in a number of
ways, including using FSO.FileExists() and it it correct.
But I'm still getting this message... Any ideas?
I also stumbled across a suggestion to simple Response.Redirect to the
file - ironically, this 1-line solution works perfectly. I assume there must
be a caveat or downside to using this technique - otherwise everybody would
be using it. Can anyone sged some light on this?
Cheers
Chris
combo that submits the post]
I have a page on our intranet that is supposed to stream an Excel sheet to
the user. I'm using pretty standard code:
sFilePath = sFileDir & sFilename
Response.AddHeader "content-disposition","attachment; filename=" & sFilePath
' Create your header information
Response.ContentType = "application/x-msexcel"
' Create and configure your object
Set oFStream = Server.CreateObject("ADODB.Stream")
oFStream.Open
oFStream.Type = 1
oFStream.LoadFromFile(sFilePath)
' Stream it to the client
Response.BinaryWrite oFStream.Read
' Cleanup
oFStream.Close
Set oFStream = Nothing
' force the end
Response.End
This works fine on the main server, but not on my development machine (XP
Pro x64). This has all worded in the past, but this is a new machine, and I
can't get it to work since I've moved across. I'm getting a 'File could not
be opened' error message. In the past, I've had this error when I wasn't
pointing at the right place or where the permissions were not configured
correctly.
Currently the IUSR user has R/W access to the whole folder where the XLS
file is (It's actually in the same folder as the ASP page at them moment).
I've also checked that the filename and path are correct in a number of
ways, including using FSO.FileExists() and it it correct.
But I'm still getting this message... Any ideas?
I also stumbled across a suggestion to simple Response.Redirect to the
file - ironically, this 1-line solution works perfectly. I assume there must
be a caveat or downside to using this technique - otherwise everybody would
be using it. Can anyone sged some light on this?
Cheers
Chris