title: Create new excel worksheet with filestream from c# reportviewer
body: <p>I have this code to <a href="http://msdn.microsoft.com/en-us/library/ms252207%28v=vs.90%29.aspx" rel="nofollow noreferrer">render a reportviewer</a>:</p>
  
  <pre><code>Warning[] warnings;
  string[] streamids;
  string mimeType;
  string encoding;
  string extension;
  
  FileStream fs = new FileStream(@"c:\output.xls", FileMode.Create);
  
  foreach (ReportViewer report in this.reports)
  {    
      byte[] bytes = report.LocalReport.Render("Excel", null, out mimeType, out encoding, out extension, out streamids, out warnings);
  
      fs.Write(bytes, 0, bytes.Length);
  }
  
  fs.Close();
  </code></pre>
  
  <p>My problem is that only the first report is viewable in the excel file with the name of the report as the worksheet name. <em>It appears as though the rest are there</em> (the file size increases) but just not formatted correctly.</p>
  
  <p><strong>How do I make each report go into a different worksheet?</strong></p>
  
  <p>Notes:</p>
  
  <p>I tried adding a <a href="http://technet.microsoft.com/en-us/library/ms155373.aspx" rel="nofollow noreferrer">device info</a> string to for startpage = 0 but that didnt help either.</p>
  
  <p>I am trying to avoid using an extra library to accomplish this, it is part of a very lightweight program.</p>
  
  <p>Similar unanswered question:
  <a href="https://stackoverflow.com/questions/20763129/how-to-export-data-to-excel-via-reportviewer-with-multiple-named-worksheets">https://stackoverflow.com/questions/20763129/how-to-export-data-to-excel-via-reportviewer-with-multiple-named-worksheets</a></p>