title: append on existing excel file via microsoft Interop c#
body: <p>Folks! I am writing a program that takes data from a website via selenium web driver. I am trying to create football fixture for our projects. So far, I accomplished to take <strong>date and time, team names and scores</strong> from the website. One or two days ago, I asked Is there any way to write data to excel file. I tried epplus, but it is not easy to use, so I started to use Interop and I have a couple of questions.</p>
  
  <p>Firstly, I need to check my file exist or not. Also, I need to access the current worksheet. Then, I need to check whether the first rows items exists or not. If it does not exist, I need to insert a new row to the index 1. I am not sure that I am doing right:</p>
  
  <pre><code>using Excel = Microsoft.Office.Interop.Excel; //namespace
  
  var filePath = new FileInfo(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) +
                  "\\Test" + "\\" + pathName + "\\" + subFile + "\\" + pathName + ".xlsx");
  
  Excel.Application xlApp = new Excel.Application();
  xlApp.Visible = true;
  object misValue = System.Reflection.Missing.Value;
  
  string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\Test" + "\\" + pathName + "\\" + subFile + "\\" + pathName + ".xlsx";
  
  if (filePath.Exists)
  {
        Excel.Workbook wb = xlApp.Workbooks.Open(path,0, false, misValue, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
        Excel.Worksheet ws = (Excel.Worksheet)wb.Worksheets.Item["Sheet1"];
        for (int i = 0; i &lt; dateTime.Count; i++)
        {
              if (string.Compare(ws.Cells[i + 1, 1], dateTime[dateTime.Count - i -1]) != 0 &amp;&amp; string.Compare(ws.Cells[i + 1, 2], firstTeam[dateTime.Count - i - 1]) != 0 &amp;&amp; string.Compare(ws.Cells[i + 1, 3], secondTeam[dateTime.Count - i - 1]) != 0)
              {
                          ws.Cells.Rows.Insert(0);
                          ws.Cells[1, 1] = dateTime[dateTime.Count - i - 1];
                          ws.Cells[1, 2] = firstTeam[dateTime.Count - i - 1];
                          ws.Cells[1, 3] = secondTeam[dateTime.Count - i - 1];
               }
         }
  }
  </code></pre>
  
  <p>I am trying to check data on the row, but i could not accomplished. My <strong>if condition not working</strong> I get this error: <code>best overloaded method match for 'string.Compare(string, string)' has some invalid arguments'</code> How can I do it? Also, Is my code right ?</p>