title: Writing a Dictionary to Excel in C#
body: <p>I have a dictionary with strings as the keys, and lists of strings as the values. I want to write the values to Excel so that the keys are on the top row and their values are in the corresponding columns. I already have some code below that will write the keys to the top row, but I'm not sure how to do the values. Thanks in advance!</p>
  <pre class="lang-vb prettyprint-override"><code>Excel.Application oXL = new Excel.Application();
  Excel._Workbook oWB = (Excel._Workbook) (oXL.Workbooks.Add(Missing.Value));
  Excel._Worksheet oSheet = (Excel._Worksheet) oWB.ActiveSheet;
  Excel.Range oRng;
  
  string[] saNames = dict.Keys.ToArray();
  
  oRng = oSheet.get_Range(&quot;A1&quot;, Missing.Value).get_Resize(1, dict.Keys.Count);
  oRng.Value = saNames;
  
  oXL.Visible = true;
  oXL.UserControl = true;
  </code></pre>