title: Excel spreadsheet generation results in "different file format than extension error" when opening in excel 2007
body: <p>The spreadsheet still displays, but with the warning message. The problem seems to occur because Excel 2007 is more picky about formats matching their extensions than earlier versions of Excel.</p>
  
  <p>The problem was initially discovered by an ASP.Net program and produces in the Excel error "The file you are trying to open, "Spreadsheet.aspx-18.xls', is in a different format than specified by the file extension. Verify ...". However, when I open the file it displays just fine. I am using Excel 2007. Firefox identifies the file as an Excel 97-2003 worksheet.   </p>
  
  <p>Here is an ASP.NET page which generates the problem:</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Spreadsheet.aspx.cs" Inherits="Spreadsheet" %&gt;
  </code></pre>
  
  <p>The code behind file looks like:</p>
  
  <pre><code>public partial class Spreadsheet : System.Web.UI.Page {
      protected void Page_Load(object sender, EventArgs e)
      {
          Response.ContentType = "application/vnd.ms-excel";
          Response.Clear();
          Response.Write("Field\tValue\tCount\n");
  
          Response.Write("Coin\tPenny\t443\n");
          Response.Write("Coin\tNickel\t99\n"); 
  
      } 
  </code></pre>
  
  <p>}</p>
  
  <p>T</p>