Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > File download - 'save' works, 'open' cannot find file

Reply
Thread Tools

File download - 'save' works, 'open' cannot find file

 
 
mo@novastar.net
Guest
Posts: n/a
 
      04-04-2006
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???

 
Reply With Quote
 
 
 
 
S. Justin Gengo
Guest
Posts: n/a
 
      04-04-2006
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


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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???
>



 
Reply With Quote
 
 
 
 
Stuart Irving
Guest
Posts: n/a
 
      04-04-2006
Does the filename/path contain either "[" or "]" characters - if so, getting
rid of them may resolve the problem.


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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???
>



 
Reply With Quote
 
blackstaronline.net
Guest
Posts: n/a
 
      04-04-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
windows cannot find my download when i go to run it. john royce Computer Support 5 08-01-2009 08:58 PM
IE cannot find internet site to download blob Roger Withnell ASP General 7 07-13-2003 07:59 PM
IE cannot find internet site to download BLOB Roger Withnell ASP General 0 07-10-2003 11:12 PM
IE cannot find internet site to download BLOB Roger Withnell ASP General 0 07-10-2003 08:43 AM



Advertisments