title: Excel spreadsheet created through code opens when opening excel
body: <p>I recently wanted to see if I could create an excel spreadsheet using c# for a task in my work. I wrote a quick program (see code below) to learn the basics and now everytime I open Excel the spreadsheet that was generated by my code is displayed. How do I stop this from happening?</p>
  
  <pre><code>namespace ExcelAddIn1
  {
      public partial class ThisAddIn
      {
          private void ThisAddIn_Startup(object sender, System.EventArgs e)
          {
              var bankAccounts = new List&lt;Account&gt;
              {
               new Account
               {
                  ID = 1, 
                  Balance = 50.00, 
                  Payee = "Debit", 
                  PayDate = DateTime.Today
               }
              };
  
              DisplayInExcel(bankAccounts, (account, cell) =&gt;
                  //This multiline lamda expression sets 
                  //custom processing rules for bankAccounts.
                  {
                      cell.Value = account.ID;
                      cell.Offset[0, 1].Value = account.Balance;
                      cell.Offset[0, 2].Value = account.Payee;
                      cell.Offset[0, 3].Value = account.PayDate;
                      if (account.Balance &lt; 0)
                      {
                          cell.Interior.Color = 255;
                          cell.Offset[0, 1].Interior.Color = 255;
                      }
                  });
          }
  
          private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
          {
          }
  
          void DisplayInExcel(
              IEnumerable&lt;Account&gt; accounts, 
              Action&lt;Account, 
              Excel.Range&gt; DisplayFunc)
          {
              var excelApp = this.Application;
              // Add a new Excel workbook.
              excelApp.Visible = true;
              excelApp.Workbooks.Add();
  
              #region cellValues
              excelApp.Range["A1"].Value = "ID";
              excelApp.Range["B1"].Value = "Balance";
              excelApp.Range["C1"].Value = "Payee";
              excelApp.Range["D1"].Value = "Date";
              excelApp.Range["A2"].Select();
  
              foreach (var ac in accounts)
              {
                  DisplayFunc(ac, excelApp.ActiveCell);
                  excelApp.ActiveCell.Offset[1, 0].Select();
  
              }
              #endregion
  
              // Copy the results to Clipboard.
              excelApp.Range["A1:D2"].Copy();
  
              excelApp.Columns[1].AutoFit();
              excelApp.Columns[2].AutoFit();
              excelApp.Columns[3].AutoFit();
              excelApp.Columns[4].AutoFit();
          }
  
          #region VSTO generated code
  
          /// &lt;summary&gt;
          /// Required method for Designer support - do not modify
          /// the contents of this method with the code editor.
          /// &lt;/summary&gt;
          private void InternalStartup()
          {
              this.Startup += new System.EventHandler(ThisAddIn_Startup);
              this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
          }
  
          #endregion
      }
  }
  </code></pre>