title: Custom export reportviewer to excel file
body: <p>I want to export the report viewer to excel file after clicking a button and hide the existing export toolstrip button that available for report viewer.</p>
  
  <p>Below is my code for ExportFile function:</p>
  
  <pre><code> private void ExportFile()
      {
    SaveFileDialog saveFileDialog1 = new SaveFileDialog();
          saveFileDialog1.Filter = "*PDF files (*.pdf)|*.pdf|Excel files (*.xls)|*.xls|Doc files      (*.doc)|*.doc";
          // Variables
          Warning[] warnings;
          string[] streamids;
          string mimeType;
          string encoding;
          string extension;
          string path = " ";
          DialogResult dr = saveFileDialog1.ShowDialog();
          path = saveFileDialog1.FileName;
  
          byte[] bytes = reportViewerForm.reportViewer1.LocalReport.Render("Excel", null, out   mimeType, out encoding, out extension, out streamids, out warnings);
  
          FileStream fs = new FileStream(path + ".xls", FileMode.Create);
          fs.Write(bytes, 0, bytes.Length);
          fs.Close();}
  </code></pre>
  
  <p>Code for button_click event:</p>
  
  <pre><code>private void btnExport_Click(object sender, EventArgs e)
      {
          this.GetData();
          this.ExportFile();
      }
  </code></pre>
  
  <p>However, I get a exception error when trying to export it. 
  Here is my inner exception:</p>
  
  <pre><code> InnerException: Microsoft.ReportingServices.ReportProcessing.ReportProcessingException
     Message=One or more parameters required to run the report have not been specified.
     Source=Microsoft.ReportViewer.Common
     ExceptionLevelHelpLink=http://go.microsoft.com/fwlink/?LinkId=20476&amp;EvtSrc=Microsoft.ReportingServices.Diagnostics.Utilities.ErrorStrings&amp;EvtID=rsParametersNotSpecified&amp;ProdName=Microsoft%20SQL%20Server%20Reporting%20Services&amp;ProdVer=1.0
     SkipTopLevelMessage=false
     StackTrace:
          at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RenderReport(IRenderingExtension newRenderer, DateTime executionTimeStamp, ProcessingContext pc, RenderingContext rc, IChunkFactory cacheDataChunkFactory, IChunkFactory yukonCompiledDefinition, Boolean&amp; dataCached)
          at Microsoft.Reporting.LocalService.CreateSnapshotAndRender(CatalogItemContextBase itemContext, ReportProcessing repProc, IRenderingExtension renderer, ProcessingContext pc, RenderingContext rc, SubreportCallbackHandler subreportHandler, ParameterInfoCollection parameters, DatasourceCredentialsCollection credentials)
          at Microsoft.Reporting.LocalService.Render(CatalogItemContextBase itemContext, Boolean allowInternalRenderers, ParameterInfoCollection reportParameters, IEnumerable dataSources, DatasourceCredentialsCollection credentials, CreateAndRegisterStream createStreamCallback, ReportRuntimeSetup runtimeSetup)
          at Microsoft.Reporting.WinForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, PageCountMode pageCountMode, CreateAndRegisterStream createStreamCallback, Warning[]&amp; warnings)
     InnerException: 
  </code></pre>
  
  <p>What parameter did I missing? Any help will be appreciated. Thank you.</p>