title: How to open an Excel file in C#?
body: <p>I am trying to convert some <a href="http://en.wikipedia.org/wiki/Visual_Basic_for_Applications" rel="noreferrer">VBA</a> code to C#. I am new to C#. Currently I am trying to open an Excel file from a folder and if it does not exist then create it. I am trying something like the following. How can I make it work?</p>
  
  <pre><code>Excel.Application objexcel;
  Excel.Workbook wbexcel;
  bool wbexists;
  Excel.Worksheet objsht;
  Excel.Range objrange;
  
  objexcel = new Excel.Application();
  if (Directory("C:\\csharp\\error report1.xls") = "")
  {
      wbexcel.NewSheet();
  }
  
  else
  {
      wbexcel.Open("C:\\csharp\\error report1.xls");
      objsht = ("sheet1");
  }
  objsht.Activate();
  </code></pre>