View Single Post
  #1 (permalink)  
Old May 1st, 2019, 03:43 PM
Ron Howerton Ron Howerton is offline
Friend of Wrox
Points: 2,876, Level: 22
Points: 2,876, Level: 22 Points: 2,876, Level: 22 Points: 2,876, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Denver, CO, USA.
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
Default Open Excel from web page

I have been told to "write some code" to open Excel from 4 different web sites and display their calling page contents. The process is currently using:

Response.ContentType = "application/vnd.ms-excel"

Which seems to accept the page's contents, but it is displaying this warning:

The file format and extension of 'filename.xls' 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?

Depending on how the user responds, they could see more warnings and dialog boxes, which is apparently further confusing users. My boss insists there's some way to avoid this warning without first saving the spreadsheet, but he has no idea how and I've been unable to find such a solution. This web site:

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

Says the Alert is a new security feature of Excel, but offers no suggestions about how to avoid it? I've tried modifying the file extension before opening Excel, but when Excel opens, the file name is changed from 'filename.xlsx' to the name of the page opening Excel: 'pagename.aspx'. This is how the Excel file name is currently being passed from ASP:

Response.AddHeader("Content-Disposition", "filename=" & File_Name)

Is there some trick to successfully passing a file name to Excel that I've overlooked? Is there some other way to open Excel that will import the page contents and produce a matching spreadsheet? I know I can open the sites from Excel, but that's too complicated for our users. They just want to click a button.

CreateObject("Excel.Application")

appears to require coding to format the spreadsheet like the page, which will require a complete rewrite of all four applications, unless I've misunderstood something?

Or is this simply not possible?
Reply With Quote