Exporting HTML Table to Excel Extension Issues

0 votes

I'm working on a page that exports an HTML table to an Excel spreadsheet by using the markup listed below to create the spreadsheet. However, whenever a new Excel document starts, I get a warning that "ExcelDocName.xls's file format and extension don't match. The file might be dangerous or corrupt." Excel cannot open the file "ExcelDocName.xlsx" because the file format or file extension is invalid, despite the fact that I assume this is happening due of the.xls extension. How should I change this markup to fix these problems?

<!DOCTYPE html><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'> 
   <meta http-equiv=Content-Type content='text/html;charset=windows-1252'><meta name=Generator content='Microsoft Excel 11'> 
   <meta name=ProgId content=Excel.Sheet> <meta name=Generator content='Microsoft Excel 11'> 
<!--table @page{}-->
<!--[if gte mso 9]><xml> <x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>  <x:Name>Sheet1</x:Name>    <x:WorksheetOptions><x:Panes> 
<body><form method='POST' action='" &APSPostName&".asp' name='frmExcel'></form>    
    <!-- Table HTML goes here -->

The following is included after the markup is created.

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename="&ExcelName&".xls"
Nov 14 in Others by Kithuzzz
• 20,660 points

1 answer to this question.

0 votes

In my application, I'm experiencing a similar issue. I've just discovered that this is a problem with Microsoft Excel, not the file itself. Starting with Excel 2007 and up to the most recent version of Excel 2016, you cannot open HTML material using Excel unless it has been saved with the.html extension.

Although you can open the file without any issues with Open Office or Libre Office if you save it with the.xls extension, Microsoft Excel will give you errors when you try to open it (2007 - Current)


  1. Save the file as a .html extension and inform the user to open it with Microsoft Excel (Once opened they can save it as an excel document).
  2. Save the file with a .xls extension and inform the user to open it with Open Office or Libre Office. to avoid the annoying error.
  3. Save the file with a .xls extension and inform the user about the error and inform them to ignore the error and click yes when it pops up.
answered Nov 14 by narikkadan
• 37,660 points

Related Questions In Others

0 votes
1 answer

How to import data from a HTML table on a website to excel?

Hello  To import any HTML file in excel there ...READ MORE

answered Feb 10 in Others by gaurav
• 22,040 points
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16 in Others by Edureka
• 13,640 points
0 votes
1 answer

Display a table (in the html/Excel spreadsheet meaning) in a iOS app in Swift

Here is the answer to your question: How ...READ MORE

answered Oct 29 in Others by narikkadan
• 37,660 points
0 votes
1 answer

Pivot Chart Table in Excel To Calculate the Count and Display the Chart

It should look something like this: READ MORE

answered Nov 6 in Others by narikkadan
• 37,660 points
0 votes
0 answers
0 votes
1 answer

Excel viewer lib

 Try http://viewerjs.org. You will need to save your ...READ MORE

answered Oct 29 in Others by narikkadan
• 37,660 points
0 votes
1 answer

How blockchain hides it's HTML source?

When you click View Source, you see ...READ MORE

answered Jul 17, 2018 in Blockchain by Shashank
• 10,400 points
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
0 votes
1 answer

Export HTML Table to Excel- Doesn't Open in Office 2010

We had the same issue too many ...READ MORE

answered Oct 21 in Others by narikkadan
• 37,660 points
0 votes
1 answer

Convert table in a jpg image to excel using python

I believe you must execute OCR (optical ...READ MORE

answered Oct 16 in Others by narikkadan
• 37,660 points
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP