I have an application that uses Reporting Services. When the user
chooses to print a report, they are taken to a window that allows them
to fill in parameters for the report. They then click a button to
either export to PDF or to EXCEL. Once the report is generated, the
byte array containing the data is put into session and an aspx page is
loaded into a hidded iframe that "prints" the report (using the byte
array from session) causing the file download dialog to appear. If you
choose "save", everything is fine - the report saves correctly. If you
choose "open", the file "cannot be found" either in Excel or
Acrobat/PDF.
If I skip the iframe, using the same page to print the report that is
used to select the params, everything works fine. I am baffled...!
Code to follow:
/* BEGIN Report Parameter Selector Page */
private void ibtnPDF_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
/* CODE LEFT OUT FOR SIMPLICITY */
rb = new SQLReportBuilder( parameterCount );
rb.ReportName = reportName;
rb.ReportPath = reportDirectory;
rb.SetRenderingFormat( SQLReportBuilder.ReportFormat.PDF );
LoadReport();
}
private void LoadReport()
{
string encoding = null;
string mimeType = null;
string[] streamIDs = null;
Warning[] warnings = null;
ParameterValue[] usedParams = null;
/* CODE LEFT OUT FOR SIMPLICITY */
byte[] result = rs.Render( rb.ReportPath + rb.ReportName,
rb.Format, rb.HistoryID, rb.DeviceInfo, rb.Parameters,
rb.DataSourceCredentials, rb.ShowHideToggle, out encoding, out
mimeType, out usedParams, out warnings, out streamIDs );
Session["__REPORTDATA"] = result;
Session["__OUTPUTFILENAME"] = reportName + rb.ReportFileExtension;
this.iframeReportDownload.Attributes.Add( "src",
"ReportDownloader.aspx" );
}
/* END Report Parameter Selector Page */
/* BEGIN Report Printing Page (ReportDownloader.aspx)*/
byte[] result = null;
string outputFileName = null;
private void Page_Load(object sender, System.EventArgs e)
{
result = (byte[])Session["__REPORTDATA"];
outputFileName = (string)Session[ "__OUTPUTFILENAME" ];
if ( result != null )
{
PrintReport();
}
}
private void PrintReport()
{
Response.Buffer = true;
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader( "Content-Disposition", "attachment; filename="
+ outputFileName );
Response.AddHeader( "Content-Length", result.Length.ToString() );
Response.BinaryWrite( result );
Response.Flush();
Response.End();
}
/* END Report Printing Page */
If I put the exact code that is in the PrintReport() function into the
LoadReport() function, in place of the line
"this.iframeReportDownload.Attributes.Add( "src",
"ReportDownloader.aspx" );" - it works just fine - I can save and open.
Does anyone know why I cannot open the file but I can save the file??? 3 3203
mo,
This isn't really a solution to your particular problem, but what about just
opening the report in a new window?
Regards,
--
S. Justin Gengo
Web Developer / Programmer
Free code library: http://www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
<mo@novastar.net> wrote in message
news:11**********************@z34g2000cwc.googlegr oups.com... I have an application that uses Reporting Services. When the user chooses to print a report, they are taken to a window that allows them to fill in parameters for the report. They then click a button to either export to PDF or to EXCEL. Once the report is generated, the byte array containing the data is put into session and an aspx page is loaded into a hidded iframe that "prints" the report (using the byte array from session) causing the file download dialog to appear. If you
choose "save", everything is fine - the report saves correctly. If you
choose "open", the file "cannot be found" either in Excel or Acrobat/PDF.
If I skip the iframe, using the same page to print the report that is used to select the params, everything works fine. I am baffled...!
Code to follow:
/* BEGIN Report Parameter Selector Page */ private void ibtnPDF_Click(object sender, System.Web.UI.ImageClickEventArgs e) { /* CODE LEFT OUT FOR SIMPLICITY */
rb = new SQLReportBuilder( parameterCount ); rb.ReportName = reportName; rb.ReportPath = reportDirectory; rb.SetRenderingFormat( SQLReportBuilder.ReportFormat.PDF );
LoadReport(); }
private void LoadReport() { string encoding = null; string mimeType = null; string[] streamIDs = null; Warning[] warnings = null; ParameterValue[] usedParams = null;
/* CODE LEFT OUT FOR SIMPLICITY */
byte[] result = rs.Render( rb.ReportPath + rb.ReportName, rb.Format, rb.HistoryID, rb.DeviceInfo, rb.Parameters, rb.DataSourceCredentials, rb.ShowHideToggle, out encoding, out mimeType, out usedParams, out warnings, out streamIDs );
Session["__REPORTDATA"] = result; Session["__OUTPUTFILENAME"] = reportName + rb.ReportFileExtension; this.iframeReportDownload.Attributes.Add( "src", "ReportDownloader.aspx" );
}
/* END Report Parameter Selector Page */
/* BEGIN Report Printing Page (ReportDownloader.aspx)*/ byte[] result = null; string outputFileName = null;
private void Page_Load(object sender, System.EventArgs e) { result = (byte[])Session["__REPORTDATA"]; outputFileName = (string)Session[ "__OUTPUTFILENAME" ];
if ( result != null ) { PrintReport(); } }
private void PrintReport() { Response.Buffer = true; Response.Clear(); Response.ContentType = "application/octet-stream"; Response.AddHeader( "Content-Disposition", "attachment; filename="
+ outputFileName ); Response.AddHeader( "Content-Length", result.Length.ToString() ); Response.BinaryWrite( result ); Response.Flush(); Response.End();
}
/* END Report Printing Page */
If I put the exact code that is in the PrintReport() function into the LoadReport() function, in place of the line "this.iframeReportDownload.Attributes.Add( "src", "ReportDownloader.aspx" );" - it works just fine - I can save and open. Does anyone know why I cannot open the file but I can save the file???
Does the filename/path contain either "[" or "]" characters - if so, getting
rid of them may resolve the problem.
<mo@novastar.net> wrote in message
news:11**********************@z34g2000cwc.googlegr oups.com... I have an application that uses Reporting Services. When the user chooses to print a report, they are taken to a window that allows them to fill in parameters for the report. They then click a button to either export to PDF or to EXCEL. Once the report is generated, the byte array containing the data is put into session and an aspx page is loaded into a hidded iframe that "prints" the report (using the byte array from session) causing the file download dialog to appear. If you
choose "save", everything is fine - the report saves correctly. If you
choose "open", the file "cannot be found" either in Excel or Acrobat/PDF.
If I skip the iframe, using the same page to print the report that is used to select the params, everything works fine. I am baffled...!
Code to follow:
/* BEGIN Report Parameter Selector Page */ private void ibtnPDF_Click(object sender, System.Web.UI.ImageClickEventArgs e) { /* CODE LEFT OUT FOR SIMPLICITY */
rb = new SQLReportBuilder( parameterCount ); rb.ReportName = reportName; rb.ReportPath = reportDirectory; rb.SetRenderingFormat( SQLReportBuilder.ReportFormat.PDF );
LoadReport(); }
private void LoadReport() { string encoding = null; string mimeType = null; string[] streamIDs = null; Warning[] warnings = null; ParameterValue[] usedParams = null;
/* CODE LEFT OUT FOR SIMPLICITY */
byte[] result = rs.Render( rb.ReportPath + rb.ReportName, rb.Format, rb.HistoryID, rb.DeviceInfo, rb.Parameters, rb.DataSourceCredentials, rb.ShowHideToggle, out encoding, out mimeType, out usedParams, out warnings, out streamIDs );
Session["__REPORTDATA"] = result; Session["__OUTPUTFILENAME"] = reportName + rb.ReportFileExtension; this.iframeReportDownload.Attributes.Add( "src", "ReportDownloader.aspx" );
}
/* END Report Parameter Selector Page */
/* BEGIN Report Printing Page (ReportDownloader.aspx)*/ byte[] result = null; string outputFileName = null;
private void Page_Load(object sender, System.EventArgs e) { result = (byte[])Session["__REPORTDATA"]; outputFileName = (string)Session[ "__OUTPUTFILENAME" ];
if ( result != null ) { PrintReport(); } }
private void PrintReport() { Response.Buffer = true; Response.Clear(); Response.ContentType = "application/octet-stream"; Response.AddHeader( "Content-Disposition", "attachment; filename="
+ outputFileName ); Response.AddHeader( "Content-Length", result.Length.ToString() ); Response.BinaryWrite( result ); Response.Flush(); Response.End();
}
/* END Report Printing Page */
If I put the exact code that is in the PrintReport() function into the LoadReport() function, in place of the line "this.iframeReportDownload.Attributes.Add( "src", "ReportDownloader.aspx" );" - it works just fine - I can save and open. Does anyone know why I cannot open the file but I can save the file???
There seems to be a problem with opening excel from an iframe window.
I had the same problem when I turned on 'SmartNavigation' which one of
its features is putting your entire page into a hidden iframe. The
minute that happened I could no longer 'OPEN' from my export to Excel
feature, but 'SAVE' continued to work fine.
I turned 'OFF' smart navigation on that page and now everything works
fine again. Try creating a workaround so you don't have to use the
hidden iframe on your .net page. I bet it will work fine if you get rid
of that iframe.
Hope it helps,
Jeremy Reid http://hgtit.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Frostillicus |
last post by:
I'm trying to get an ASP to return a zip file to the remote browser from an
Image (BLOB) field in SQL Server 2000 but Internet Explorer keeps...
|
by: Dorsa |
last post by:
HI, Could you please tell me the error in here. I am trying to open an
XML file from a link.
Response.Clear()
Response.Expires = 0...
|
by: ntm |
last post by:
I am using the following ASPC.VB code to download a text file:
Response.Clear()
Response.ContentType = "ignore/this" ' arbitrary...
|
by: theyas |
last post by:
How can I get my code to NOT display two "Open/Save/Cancel/More Info" dialog boxes when using the "Response.WriteFile" method to download a file to...
|
by: Guy Penfold |
last post by:
Hi All,
I have an asp.net 1.1 application that includes a rudimentary contacts database that must support importing from and exporting to Outlook....
|
by: Roy |
last post by:
Hi,
I have a problem that I have been working with for a while.
I need to be able from server side (asp.net) to detect that the file i'm...
|
by: AirYT |
last post by:
Hello,
Here's a quick explanation & problem:
i have an ASP (iis v5.0) application that generates a pdf file and this file
is saved to the...
|
by: aljosa.mohorovic |
last post by:
I have a problem when doing indirect download of file through php, when
I click on download link Firefox and Internet Explorer give me same...
|
by: rafi |
last post by:
Hi,
I developed a website using php5 & mysql5. One of its features is the
ability of users to upload files to the server, and allow other users...
|
by: tammygombez |
last post by:
Hey fellow JavaFX developers,
I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
|
by: concettolabs |
last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
|
by: better678 |
last post by:
Question:
Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct?
Answer:
Java is an object-oriented...
|
by: CD Tom |
last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
|
by: CD Tom |
last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
| | |