Still searching for my PRINTs with content-type Excel

My previous thread turned into a discussion of a sub-problem (and resolved it!), so I am starting a new thread.

I am trying to export data to Excel over the Web. The data is in an HTML field (an INPUT) within an HTML Form:

The Export button is in a different Form in the same frame. When the user clicks it, Javascript code starts myAgent:

document.forms[‘EXPOFORM’].submit() ;

The LotusScript agent receives the POST properly, sees the data in Request_Content, and tries to output a table to Excel via the browser:

Print “Content-Type:application/vnd.ms-excel”

Call agentlog.logaction(“Printed Content-Type:application/vnd.ms-excel”)

’ Ensure the open/save dialog will appear in IE

Print |Content-Disposition:Attachment; filename=“Report.xls”|

Print |

|

For i = 0 To (Ubound( ArrayOfRows ) - 1) ’ Split leaves extra row due to trailing delimiter

Print |

|

’ Divide each row into the cell values

ArrayOfCells = Split(ArrayOfRows(i), ColDelim)

For j = 0 To Ubound( ArrayOfCells )

t = ArrayOfCells(j)

Call agentlog.logaction("Print a cell " + t )

Print "<TD>" + t + "</TD>"

Next

Print “

Next

Print |

|

The agentLog shows that the Print statements are executing as planned. And this technique has worked fine at other points during development. It has displayed the “Open or Save File” dialogue for the file report.xls .

But now, the table does not appear. And the table does not display anywhere either. It looks like nothing happens when you click the “Export” button, but, the agentLog shows that the agent runs properly.

Any ideas what is going wrong? The browser is IE 6.0 SP2 on XP .

Subject: Still searching for my PRINTs with content-type Excel

In my experience, Domino is not happy about code lines that both assemble and out-print a string. This line:

Print “” + t + “/TD>”

should be split into:

outString = “” + t + “”

Print outString

I don’t know why it works that way, but it’s been a consistent fix for me.

Subject: RE: Still searching for my PRINTs with content-type Excel

I changed this, but no luck.

Subject: RE: Still searching for my PRINTs with content-type Excel

Hmmm… you probably should have bought the tickets to Tibet before the big oil price bump.

Another thing to try – hard-print a chr$(13) after every line. Excel doesn’t like it when a there’s more than one cell per line, or when and don’t appear on their very own lines.

Subject: RE: Still searching for my PRINTs with content-type Excel

I have tried those things and no luck. Also tried stripping out the logging code - no luck.

I traced with Ethereal and found that the right stuff is coming back to my PC after the submit! Specifically it is an “HTTP1.1 200 OK” response, followed by the file.

In testing I determined that, other things being equal, a GET causes the agent to send back the same data. (The GET occurs when I use

document.location.replace=URL;

rather than

document.forms[0].submit();

in the script.) But for the GET, the data is handled (displayed) as I expect.

I also found that IE is not responding if I take out the “Content-Type” and “Content-Disposition” headers. If I use a GET, without printing the headers, the HTML displays in the browser as expected; but after my POST nothing happens.

So it looks like Domino is doing the right thing, but Internet Exploder cannot cope. After a POST it only wants HTML.

Yet elsewhere I see POSTs that work right and display what the server sends out. What am I missing???

Subject: RE: Still searching for my PRINTs with content-type Excel

Well, if a GET works, then get getting. I have no idea why IE acts like that. Maybe the answer lies on a mountaintop in Tibet…

Subject: RE: Still searching for my PRINTs with content-type Excel

I’d gladly GET going, but my data exceeds the URL-length limitations.

There must be a reason IE does this - I’m willing “Tibet” on it! I’ll post if I find it.

Subject: RE: Still searching for my PRINTs with content-type Excel

Richard

Did you ever find a solution to this? We appear to be having exactly the same issue - but it appeared only on moving the clients to SP2.

We have a form being submitted, and the WebQuerySave agent prints out the HTML table tags, with a Print “Content-Type:application/vnd.ms-excel” at the start. This worked perfectly in IE6/SP1, but on IE6/SP2 clients, Excel is never displayed.

Was your problem related to SP2? Did you try it in SP1?

Thanks

Tim