title: Fast Way to Update part of Excel worksheet from C# Interop Add In
body: <p>I'm trying to find a fast way to update an Excel Spreadsheet (C# Interop). This is an Excel Add In and the worksheet will have about 20000 rows when fully populated. My current process is as follows:</p>
  
  <ul>
  <li>I subscribe to a service for events</li>
  <li>When I get the first event I process a State of the World where I fill an array and rapidly fill the spreadsheet. This takes a few seconds to complete but the performance is fine. At the same time I fill a Dictionary with a key and a class containing the Excel address and Cell value.</li>
  <li><p>Subsequent events I receive should be considered updates/inserts. This means I need to iterate through my Dictionary and see what has changed (this is fast enough). The slow part is the code below where I get the Excel range in a loop and update the changed value:</p>
  
  <pre><code>Globals.MyAddIn.Application.ScreenUpdating = false;
  XL.Range add1 = activeWorksheet.get_Range(xlDataPoint.ExcelAddress);
  xlDataPoint.Value = value.ToString();
  add1.Value2 = value;
  Globals.MyAddIn.Application.ScreenUpdating = true;
  </code></pre></li>
  <li><p>Since some cells change and others dont - I only want to update those where the value has changed. I also need to keep the worksheet responsive to the user.
  What can I do to speed up the updating of my spreadsheet (I suspect the answer would be the same in VBA or C#.)?</p></li>
  </ul>