Pages

Friday, August 26, 2016

Excel Files From Web Won't Open

0 comments
I had an interesting issue creep up a bit ago with Excel files that were created by a web application not opening in Excel.

I had a ColdFusion app that would generate reports on the fly for users.  We were using CFHEADER and CFCONTENT to deliver table formatted data as XLSX files.  It had been working fine right up until it didn't.  We hadn't made any changes to the code and checked and confirmed that there were no changes/patches to the system since the last known good report was generated.

As it turns out, in mid-July Microsoft upgraded the security in Excel concerning how it handled HTML files with XLS or XLSX extensions from untrusted locations. Previously, Excel would warn you about the file having a type mismatch and would let you accept opening the file.  From the update, Excel would no longer allow the file to be opened and offered no explanation or error message.

There are a couple of workarounds to open the files:
The first is on a file by file basis -
  • Once you have the file, Right-Click on it to get the context menu and select ‘Properties’
  • On the ‘General’ tab, click ‘Unblock’ and then ‘OK’
  • Open the file as usual. You’ll get this message - 'The file format and extension of filename don't match. The file could be corrupted or unsafe. Unless you trust its source don't open it. Do you want to open it anyway?'
  • Click ‘Yes’
  • The file will open
Another workaround is to change the Trusted Locations settings in Excel

  • Open File > Options > Trust Center > Trust Center Settings > Protected View
  • Clear the check-marks from  "Enable Protected View for file originating from the Internet" and “Enable Protected View for files located in potentially unsafe locations”.
  • Files pulled from the Internet will open.
If you've been building spreadsheets in ColdFusion with CFCONTENT and CFHEADER, it's time to start using CFSPREADSHEET and the associated functions.




Leave a Reply

Labels