Content-Type excel in WebQuerySave: Searching for my Prints

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.

Subject: Content-Type excel in WebQuerySave: Searching for my Prints

When you use a WebQuery agent, the Request_Content is parsed into NotesDocument items, so you need to have corresponding fields on the form, and you need to get the content from those fields. (WQS happens after the doc and the form are “married”.)

Subject: RE: Content-Type excel in WebQuerySave: Searching for my Prints

Thanx for the insight. The logs show that the data is coming in from the field successfully. It’s just that the Print statements are having no (visible) effect.

I should clarify: if I could access Request_Content in an agent, I wouldn’t use submit() and WebQuerySave(), I would just use an URL with ?OpenAgent. But I found by logging and tracing that the other CGI variables work, but doc.Request_Content(0) was always a null string. (I did put the Request_Content field onto the form.)

The data in the fields is smaller than the 64K limitation that was mentioned in other posts here. In my tests it is about 2K.

We are on Release 6.5.3.

Subject: RE: Content-Type excel in WebQuerySave: Searching for my Prints

If you call an agent directly by URL, the request content is in Request_Content. It’s only moved out when there’s a form involved at the server (the form is the “CGI script” for the request).

Subject: RE: Content-Type excel in WebQuerySave: Searching for my Prints

I’ve switched it so I am now using an URL with ?OpenAgent . The agent executes but it sees doc.Request_Method(0) = “GET”

and

doc.Request_Content(0)= “”

I saw a tip to make this a POST instead, but now I cannot find it.

The agent kicks off with

exURL = ‘/myDB.nsf/MyAgent?OpenAgent&VF=’ + parent.ViewFrame.location ;

parent.ViewFrame.location = exURL ;

Thanx for all the help!

Subject: RE: Content-Type excel in WebQuerySave: Searching for my Prints

If the method is GET, then the data is in Query_String. The data is in Request_Content when the method is POST.

Subject: RE: Content-Type excel in WebQuerySave: Searching for my Prints

That is GOLD! Thanx Stan. Now to test it out … If I don’t post again, either it worked, or, I gave it up and went to Tibet to meditate for a few years :slight_smile:

Subject: RE: Content-Type excel in WebQuerySave: Searching for my Prints

A more complete explanation of what is available is here:

http://www-10.lotus.com/ldd/46dom.nsf/0/9ed084a3d9e7dc0b85256f34004342f4