Exporting HTML Table to Excel Extension Issues
<p>I am working on an existing page which exports a HTML table to Excel by building an excel document with the markup below. Whenever the new Excel document opens, however, I receive a warning saying that <em>"The file format and extension of 'ExcelDocName.xls' don't match. The file could be corrupted or unsafe."</em> I suspect this is happening because of the .xls extension, but simply changing xls to xlsx gives me a message stating <em>"Excel cannot open the file 'ExcelDocName.xlsx' because the file format or file extension is not valid."</em> How should I edit this markup to eradicate these issues? </p>

<pre><code>&lt;!DOCTYPE html&gt;&lt;html  xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'&gt; 
&lt;head&gt;  
   &lt;meta http-equiv=Content-Type content='text/html;charset=windows-1252'&gt;&lt;meta name=Generator content='Microsoft Excel 11'&gt; 
   &lt;meta name=ProgId content=Excel.Sheet&gt; &lt;meta name=Generator content='Microsoft Excel 11'&gt; 
&lt;style&gt; 
&lt;!--table @page{}--&gt;
&lt;/style&gt;
&lt;!--[if gte mso 9]&gt;&lt;xml&gt; &lt;x:ExcelWorkbook&gt;&lt;x:ExcelWorksheets&gt;&lt;x:ExcelWorksheet&gt;  &lt;x:Name&gt;Sheet1&lt;/x:Name&gt;    &lt;x:WorksheetOptions&gt;&lt;x:Panes&gt; 
&lt;/x:Panes&gt;&lt;/x:WorksheetOptions&gt;&lt;/x:ExcelWorksheet&gt;&lt;/x:ExcelWorksheets&gt;&lt;x:ExcelWorkbook&gt;&lt;/xml&gt;&lt;![endif]--&gt; 
&lt;/head&gt;
&lt;body&gt;&lt;form method='POST' action='" &amp;APSPostName&amp;".asp' name='frmExcel'&gt;&lt;/form&gt;    
    &lt;!-- Table HTML goes here --&gt;
&lt;/body&gt;&lt;/html&gt;
</code></pre>

<p>The following is included after the markup is created.</p>

<pre><code>Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename="&amp;ExcelName&amp;".xls"
</code></pre>