title: Exporting excel error : File you are trying to open FileName is in different format than specified extension
body: <p>I have used following code to export data from dataset to excel file:</p>
  
  <pre><code> public void ExportRecords(System.Data.DataTable dt, String fileName)
      {
          try
          {
              if (dt.Rows.Count &gt; 0)
              {
                  string path = AllinAudio_Temp;
                  string timestamp = Convert.ToString(DateTime.Now);
                  timestamp = timestamp.Replace(" ", "");
                  timestamp = timestamp.Replace("/", "");
                  timestamp = timestamp.Replace(":", "");
                  fileName = fileName.Replace(" ", "");
  
                  string filename = path + @"\" + timestamp + "_" + fileName + ".xls";
                  CarlosAg.ExcelXmlWriter.Workbook book = new CarlosAg.ExcelXmlWriter.Workbook();
  
                  //// Add a Worksheet with some data
                  CarlosAg.ExcelXmlWriter.Worksheet sheet = book.Worksheets.Add("Sheet1");
                  WorksheetStyle style = book.Styles.Add("HeaderStyle");
                  style.Font.Bold = true;
                  WorksheetStyle style1 = book.Styles.Add("HeaderStyle1");
                  style1.Font.Bold = true;
                  style1.Font.Color = "Red";
  
                  WorksheetRow row;// = sheet.Table.Rows.Add();
  
                  row = sheet.Table.Rows.Add();
                  foreach (DataColumn column in dt.Columns)
                  {
                      row.Cells.Add(new WorksheetCell(column.ColumnName, "HeaderStyle"));
                  }
  
  
  
  
                  for (int i = 0; i &lt; dt.Rows.Count; i++)
                  {
                      row = sheet.Table.Rows.Add();
  
                      for (int l = 0; l &lt; dt.Columns.Count; l++)
                      {
                          row.Cells.Add(dt.Rows[i][l].ToString());
  
  
                      }
  
  
                  }
  
                  book.Save(filename);
                  Response.ContentType = "text/excel";
                  Response.AppendHeader("Content-Disposition", "attachment; filename=" + timestamp + "_" + fileName + ".xls");
                  Response.TransmitFile(filename);
                  Response.End();
  
  
              }
          }
          catch (Exception)
          {
  
              throw;
          }
      }
  </code></pre>
  
  <p>When the file gets exported and we try to open it, it gives me message:</p>
  
  <p><img src="https://i.stack.imgur.com/IWf3r.jpg" alt="enter image description here"></p>
  
  <p>I want the file in xls format only and i am also exxporting it in xls format.</p>
  
  <p>But why this kind of error comes when i try to open it.</p>
  
  <p><strong>When i tried with XLSX</strong></p>
  
  <p><img src="https://i.stack.imgur.com/qdCQu.jpg" alt="enter image description here"></p>