I have two agents that use this trick to export search results to MS-Excel: First, print the MIME-type header
Print “Content-Type:application/vnd.ms-excel”
then, print out an HTML table, which will open as a spreadsheet page in Excel:
Print |
|etc
The first agent is invoked via JavaScript with
location.replace(“/searchdb.nsf/ExportAgent?OpenAgent&q=flu&max=20_etc_”) ;
It works fine!
But, under other circumstances, the same script, in the same frame, uses
document.forms[0].submit() ;
to kick off the other agent as a WebQuerySave agent. This agent prints the same things in order to export to Excel. BUT nothing happens. The printed table isn’t displayed in IE, and it doesn’t open in Excel. Agent logs prove that the Prints are happening. I have tried:
–rename the agent to end in .xls
–Add Print |Content-Disposition:Attachment; filename=“Report.xls”| after the first Print
–ensure that the Content-Type header is the first Print that executes
–remove MessageBox calls
–put in a SaveOptions field set to “0”, and, set to “1”
Sometimes after testing, when I try to close Internet Explorer, I get a dialog box saying it is busy.
BTW, using WebQuerySave is necessary because the second agent needs to see fields on the search form, but, the Request_Content CGI variable is always empty. If anybody knows a way to get Request_Content working, this question will be moot.