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,  null out  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();   
        }        

你可能感兴趣的:(view)