Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: HTML output to Excel

$
0
0
Re: HTML output to Excel
Web Connection 5.0
Re: HTML output to Excel
04/15/2012
04:06:50 PM
3HA0YJG0Y Show this entire thread in new window
Gratar Image based on email address
From:
Russell Campbell
To:
Attachments:
None
Ok, I had a chance to look at this more closely. Your suggestion assumes I'm starting with an XLS file already on disk. In the past, it was possible to serve up standard table-based HTML, change the ContentType to "application/vnd.ms-excel" and the browser (IE, at least) would open Excel in the browser (or maybe it started Excel separately) and you could then save it as an XLS file to your disk. But that same code does not work in newer versions of IE, 8 and 9, I guess, and so I need a better way.

You can get it done now, but you get warnings. First I get this a dialog that says "What do you want to do with Analysis.xls?" and gives you Open, Save, Save As as your choices. So if you choose Open, you then get a dialog that says "The file you are trying to open, Analysis.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?" Then you get Yes and No choices.

Then it opens in Excel as Analysis.loc (notice that before it was saying xls and now loc as the extension, which is the scriptmap extension). Then when you try to do a Save As, it comes up with no file name and Web Page as the file type. I put the name as Analysis and change the file to Excel workbook and get Analysis.XLSX saved, but this is lots more work for the user than it used to be and I think it's due to security-related changes they've made in Windows or IE or both.

One of the advantages of doing it this way is that you get column headers from the HTML, which don't really exist in the underlying data that I used to build the HTML (except in that the field names are the column headers, but they are more readable in HTML, where they have std. names and not just a cryptic field name with no spaces).

The client wants it work like it used to, which was more seamless.



How are you serving the data?

This works for me with IE 9 (and IE 9 in Compatibility mode):

FUNCTION ServeExcelDocument lcFile = FILETOSTR("c:\saved\Travel2012.xls") Response.ContentType="application/vnd.ms-excel" Response.Write(lcFile) ENDFUNC

and just saves the file to disk. Most other browsers just download the file. If you want more control you can also use the FileAttachment header. Look into Response.DownloadFile or Response.TransmitFile.

If you want to open the Excel document in the browser I think you need to send back a different format - .csv should work to open in Excel if it's just data.

+++ Rick ---


Ping . . . any thoughts here? Is this built into WWWC and perhaps I'm missing it? It seems like tighter browser security . . .




HTML Help Builder

Viewing all articles
Browse latest Browse all 10393

Trending Articles