title: C# working with Excel via COM: how to replace the whole workbook with another one?
body: <p>I develop an application, that generates rich Excel file (report) with charts, data, etc.
  My program now just saves generated result in a file and launches it:</p>
  
  <pre><code>byte[] reportBytes = getReport(...);
  string reportFilename = "report.xls";
  
  Excel.Application oXL;
  Excel.Workbook oWB;
  
  try
  {
      oXL = (Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
      oWB = oXL.Workbooks[name];
      oWB.Close(false);
  }
  catch (Exception ex)
  {
      //
  }                
  
  File.WriteAllBytes(reportFilename, reportBytes);
  Process.Start(reportFilename);
  </code></pre>
  
  <p>And in this code opened Excel workbook is closed and reopened (that causes blink) every time when i launch my app. 
  I'd like to have Excel workbok opened due development process and get report updates dynamically  after each launch. I believe COM technology can do it.</p>
  
  <p>I need to replace all content of opened workbook by one from another (temporary) .xls file. Could you give me working example please?</p>