locked
gridviewexportutil creating XLS files suddenly generating "the file format and extension don't match" error RRS feed

  • Question

  • User-511995934 posted

    I have a web app that has been running fine for years. recently, users are reporting that when they click "export to excel", which uses the gridviewexportutil to create a older XLS file, they receive the error message "the file format and extension don't match" error

    has anyone encountered this or know how to fix it?

    Tuesday, February 27, 2018 3:17 PM

All replies

  • User753101303 posted

    Hi,

    You export HTML markup pretending this is an XLS file and since few version users are warned agains this kind of discrepancy. Also it is inconvenient for users as they don't always realize this and they can have strange messages down the road if adding unsupported stuff to what is actually an HTML file.

    Try perhaps to keep the mime type but keep a .htm extension to see what happens. At some point I would consider to create true XLS (or XLSX file) using the OpenXML SDK or some other Excel file generation Library.

    Tuesday, February 27, 2018 6:39 PM
  • User-511995934 posted

    I'm using the gridview export utility to create an excel file. it comes up and says "do you want to open myfilename.xls or save?

    it's only after excel then launches and tries to open the xls file that the error is generated. I believe Microsoft added a patch the excel to generate this error in order to prevent backward compatability issues. it HAD been working just fine. for YEARS.

    Tuesday, February 27, 2018 6:49 PM
  • User-707554951 posted

    Hi threeo

    https://blogs.msdn.microsoft.com/vsofficedeveloper/2008/03/11/excel-2007-extension-warning-on-opening-excel-workbook-from-a-web-site/

    That is a link basically describing that MS knows about the problem your describe and that it cannot be suppressed from within ASP.NET code. It must be suppressed/fixed on the client's registry.

    Best regards

    Cathy

    Wednesday, February 28, 2018 8:44 AM
  • User753101303 posted

    Excel was upgraded or patched. It behaves this way since Excel 2013 if not Excel 2007 (for example if you renamve a xls file to xlsx or the other way round).

    IMO your best bet is to embrace this change and to generate true XLS or XLSX file.

    Thursday, March 1, 2018 8:09 AM