I wanted to give a big THANK YOU to Alpha for giving me help with an issue I was having with my users and their attempts to export grid data to Excel. Here is a video about the issue: http://screencast.com/t/pRB8k3KAU
Below is the code that Alpha sent me to handle this. (Except I added all the verbage about Open versus Save etc., window title, and link verbage).
I hope this helps someone else.
Below is the code that Alpha sent me to handle this. (Except I added all the verbage about Open versus Save etc., window title, and link verbage).
I hope this helps someone else.
Code:
function OpenDownloadWindow as v (e as p) 'This function is called on the server after the records have been exported, 'and the export file has been created. dim b as b b = file.to_blob(e.exportfilename) dim key as c key = "sessfile" + time("hms3",now())+ ".xls" session.saveDataAsFile(key,b) dim url as c url = Session.FormatFileDataURL(key) 'prevent the built-in file download e.abort = .t. 'send a javascript response to the client dim js as c js = <<%js% {grid.object}._showWindow = function(url) { var windowName = 'filedownload'; var currWindow = {Grid.object}.getWindow(windowName); if(!currWindow) { currWindow = {Grid.object}.createWindow(windowName,'modal', {body: {content: {type: 'blank',elementId: '~'}}, height: '3in', width: '7in', title: {html: 'Open or Save Excel File',location: 'top'}, disableMove: false, theme: '{grid.style}' } ); } var windowDiv = currWindow.getWindowId('body'); var arrHTML = ['<b>Your Excel file has been created.</b><br><br>To Open the file, just click the link. However, depending on how your browser decides to open the file, you may NOT be able to Save the file after it opens.<br><br>To SAVE the file, right-click the link and select Save As.<br><em>(Depending on your browser, it might be called Save Target As OR Save Link As .)</em><br><br>We recommend right clicking on the link and saving the file for best results.<br><br>']; arrHTML.push('<a target="_blank" href="'+url+'"><font size=+1>Right-Click this link to Save (recommended) OR Click this link to Open.</font></a>'); var windowHTML = arrHTML.join('\n'); $(windowDiv).innerHTML = windowHTML; currWindow.show(); } %js% js = js +";" + crlf() + "{grid.object}._showWindow('" + js_escape(url) + "');" e.rtc.A_AjaxResponses[].text = js e.rtc.A_AjaxResponses[..].id = 100000 end function