Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to suppress the file corrupt warning at Excel download?

I have a web page which links to an Excel 2007 worksheet. It is a .xls file and not .xlsx file. When I click on the link I get the usual dialog box to either open/save the Excel file. On clicking 'Open', I get the following warning message-

The file you are trying to open, 'filename.xls' is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?

Can I some how suppress this warning message programmatically (i.e. to hide it or prevent it from showing up?) I'm using ColdFusion for web development.

like image 677
Arnkrishn Avatar asked Jun 02 '09 15:06

Arnkrishn


People also ask

How do you get rid of Excel warnings?

Hide error indicators in cellsOn the Excel menu, click Preferences. , and then clear the Enable background error checking check box.

Why does Excel keep saying my file is corrupted?

The main causes for "the file is corrupted and cannot be opened" in Microsoft Excel or Office are: The changes of settings in Microsoft Office after upgrading or reinstallation. Protection of your computer against the files come from another computer. The Excel or Word file is corrupted.

Why does my Excel file have ~$?

A file whose name starts with ~$ is almost certainly a temporary file created by Excel when you open a workbook. For example, when you open a workbook named Products. xlsx, Excel will create a temporary file ~$Products.


2 Answers

If you don’t want to look for a solution, but just want to solve the problem, insert this key in your registry to suppress the notification:

[HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Security] “ExtensionHardening”=dword:00000000

You can accomplish the above by doing the following:

  1. Open your Registry (Start -> Run -> regedit.exe)
  2. Navigate to HKEY_CURRENT_USER\SOFTWARE\MICROSOFT\OFFICE\12.0\EXCEL\SECURITY
  3. Right click in the right window and choose New -> DWORD
  4. Type “ExtensionHardening” as the name (without the quotes)
  5. Verify that the data has the value “0″
like image 150
jgallant Avatar answered Sep 22 '22 07:09

jgallant


This problem results from a feature called Extension Hardening, and you can find more information about it here

I've run into this problem a lot in my projects, and like Jon said, turning off Extension Hardening is something that will have to be done by each client side user.

Unfortunately, the link above also states that there are no expected changes to this code until at least Office 14.

like image 38
Matthew Jones Avatar answered Sep 22 '22 07:09

Matthew Jones