title: Convert Excel into Memory Stream and download via AngularJS
body: <p>I want to create a Excel file dynamically in C# and I need to make it as downloadable in AngularJS HTML Button Click.</p>
  
  <p>I referred the following link to create Excel dynamically <a href="http://www.increvcorp.com/manipulating-excel-spreadsheet-using-c/" rel="nofollow noreferrer">http://www.increvcorp.com/manipulating-excel-spreadsheet-using-c/</a></p>
  
  <p>It's working fine. But it saves the file in local storage</p>
  
  <pre><code> xlWorkBook.SaveAs("D:\\Mobile_List.xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
  </code></pre>
  
  <p>I referred one more post, they given idea to <strong>convert directly from workbook to Memory Stream</strong> - <a href="https://stackoverflow.com/questions/8201774/convert-excel-workbook-to-byte">Convert excel workbook to byte[]</a>.</p>
  
  <p>But, in that post they used the </p>
  
  <pre><code>MemoryStream m = new MemoryStream();
  workbook.SaveToStream(m);
  </code></pre>
  
  <p>I Can't able to find the method <code>SaveToStream</code> in my workbook, it shows an error</p>
  
  <blockquote>
    <p>'Microsoft.Office.Interop.Excel.Workbook' does not contain a
    definition for 'SaveToStream' and no extension method 'SaveToStream'
    accepting a first argument of type
    'Microsoft.Office.Interop.Excel.Workbook' could be found (are you
    missing a using directive or an assembly reference?)</p>
  </blockquote>
  
  <p>How could I make it as memory stream and send it back to AngularJS for download by clicking the HTML Button ?</p>
  
  <p>I referred one more post to <a href="https://stackoverflow.com/questions/22447952/angularjs-http-post-convert-binary-to-excel-file-and-download">AngularJS $http-post - convert binary to excel file and download</a> - it purely explained the angularJS part and PHP. There is no explanation for C#, that's the main reason I'm posting this question.</p>
  
  <p>Kindly assist me...</p>
  
  <p>Note: Don't convert it from local storage...</p>