all groups > sql server reporting services > august 2004 >
You're in the

sql server reporting services

group:

rendering to browser instead to file


RE: rendering to browser instead to file debra doty
8/25/2004 11:39:01 AM
sql server reporting services:
If you can tolerate a dialog box asking if the user wants to open or save,
this will work:

Response.ClearContent();
Response.ClearHeaders();
Response.AppendHeader("Content-Disposition",
"attachment;filename=\"MyReport.xls\"");
Response.BinaryWrite(result);

Response.End();

It works for PDF as well. There may be other ways, but this worked for us
so we stuck with it.


[quoted text, click to view]
rendering to browser instead to file Renato Aloi
8/25/2004 11:51:13 AM
Did anyone have rendered a report in excel format directly to browser
instead to a file? I tried this code below wich works fine for pdf
rendering:

result = rs.Render("/MyReports/SVREL00104", "Excel", Nothing, _
Nothing, params, Nothing, _
Nothing, encoding, mime, history, warnings, streamsId)

Page.Response.ClearContent()
Page.Response.ClearHeaders()
Page.Response.ContentType = mime
Page.Response.BinaryWrite(result)
Page.Response.Flush()
Page.Response.Close()

This code should load the excel into the web browser window, but I'm getting
this errors:

1. A message box saying: The Microsoft Excel can not access the file:
'http://localhost/MyReports/test.aspx'.

2. An input box asking for an alternate name for 'Titulos_de_Impressao'
(Print Title) because this is already an internal name.

Any ideas?

[]s
Renato

--
-----------------------------------------------------
Renato Aloi
Analista Programador
J&W Informática Ltda.
+55 11 30406675

Re: rendering to browser instead to file Renato Aloi
8/27/2004 12:22:04 PM
Thanks for your idea, Debra. Though I was really trying to avoid these
dialog boxes. In fact I am 'translating' all my systems' reports from
Crystal Reports to Reporting Services. The problem is my clients are already
using my systems with this export option to excel, without needing to save
any file. If I barelly whisper that they will need to take more clicks to do
something that is already working well, I will be exterminated.

However, I think the approach i will adopt is save a file to disk then use
this code:

Page.Response.ClearContent()
Page.Response.ClearHeaders()
Page.Response.ContentType = mime
Page.Response.WriteFile(savedFile)
Page.Response.Flush()
Page.Response.Close()

This approach works fine without any dialog boxes. The problem is at my
clients using web farms with load balance. I am afraid of exceptions, like
file not found.

Any other ideas, let me know, please.

[]s
Renato


"debra doty" <debradoty@discussions.microsoft.com> escreveu na mensagem
news:22D7671D-13F2-413F-84B8-022E222F3A4C@microsoft.com...
[quoted text, click to view]

AddThis Social Bookmark Button