report from reportviewer without viewing the control

It exports both xls and pdf.  Try that.
private void ExportData(LocalReport report, string extension)   
        {   
            
// Out params to pass into the Render method   
            Microsoft.Reporting.WebForms.Warning[] warnings;   
            
string[] streamids;   
            
string mimeType, encoding, extensionOut;   
  
            report.EnableHyperlinks 
= true;               
            
byte[] bytes = report.Render(extension, nullout mimeType,   
                                        
out encoding, out extensionOut,   
                                        
out streamids, out warnings);   
  
            Response.Clear();   
            Response.ContentType 
= mimeType;               
            Response.AppendHeader(
"Content-Disposition",    
                    
string.Format("attachment; filename={0}.{1}",   
                    DateTime.Now.ToString(
"yyyyMMdd"), extensionOut));   
            Response.BinaryWrite(bytes);   
            Response.End();   
        }        

posted on 2009-09-03 11:41  博览潇湘  阅读(233)  评论(0)    收藏  举报

导航