title: How to fix file format and extension don't match?
body: <p>I created a code in c# which creates and saves excel file. The code can successfully create and save excel file, but when I open the excel file created, it displays a warning message telling:</p>
  
  <blockquote>
    <p>The file format and extension of 'filename.xls' don't match. The file could be corrupted or unsafe. Unless you trust its source, don't open it. Do you want to open it anyway?</p>
  </blockquote>
  
  <p>I am using the following code:</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
      {
          saveFileDialogSummary.Filter = "Excel Flie|*.xls";
          saveFileDialogSummary.FilterIndex = 0;
          saveFileDialogSummary.RestoreDirectory = true;
          saveFileDialogSummary.CreatePrompt = true;
          saveFileDialogSummary.Title = "Export Excel File To";
  
          Excel.Application ExcelApp = new Excel.Application();
          ExcelApp.Application.Workbooks.Add(Type.Missing);
          ExcelApp.Columns.ColumnWidth = 30;
          for (int i = 0; i &lt; dataGridViewSummary.Rows.Count; i++)
          {
              DataGridViewRow row = dataGridViewSummary.Rows[i];
              for (int j = 0; j &lt; row.Cells.Count; j++)
              {
                  ExcelApp.Cells[i + 1, j + 1] = row.Cells[j].ToString();
              }
          }
  
          DialogResult res = saveFileDialogSummary.ShowDialog();
          if(res == DialogResult.OK){
              ExcelApp.ActiveWorkbook.SaveCopyAs(saveFileDialogSummary.FileName);
              ExcelApp.ActiveWorkbook.Saved = true;
              ExcelApp.Quit();
          }
      }
  </code></pre>
  
  <p>What should I do to avoid receiving that warning message?</p>