Technorati tags: Show-n-Tell Thursday,
Lotus Domino,
Domino
This tip falls into the category of
"I knew that.". But like the other 10,000 pieces of data that I knew, it was gone, until a phone call with
Rob recalled it.
Domino Designer help has a nice document titled:
"Using an agent to generate XML" that describes how to create an agent that feeds XML back to the browser. I have used this approach in several places to get data. The key is to start the output with a specially formated line:
Print "Content-type: text/xml" 'Prevents Domino from sending default headers.
Then you simply use print statements to output the XML you want to send to the browser;
Print |<TopLevel>|
Print |<NextLevel>This is the text at next level node 1</NextLevel>|
Print |<NextLevel>This is the text at next level node 2</NextLevel>|
Print |</TopLevel>|
When modern browsers receive this line they go into XML mode which allows you to see and process the XML output dfrom the agent.
So, what about Excel?
Well it turns out that there are many other content types you can specify that cause browsers to behave differently. One of them is:
Print |Content-Type:application/vnd.ms-excel |
This makes the browser expect that the data stream will be an MS Excel spreadsheet. Following this line, you can tell the browser what to do with the results so it will force the Open/Save dialog.
Print |Content-Disposition:Attachment; filename="AIExport.xls"|
After this, you simply need to create an HTML Table and the rows and cells of that table become the content of the Excel spreadsheet:
Print |<TABLE>|
Print |<TR><TD>Cell A1 Content</TD><TD>Cell B1 Content</TD></TR>|
Print |<TR><TD>Cell A2 Content</TD><TD>Cell B2 Content</TD></TR>|
Print |<TR><TD>Cell A3 Content</TD><TD>Cell B3 Content</TD></TR>|
Print |</TABLE>|
Of course you can play with formatting such as fonts and widths in your cells. Some work, others don't. You can also do some formulas as your content: =Sum(A1..A3), etc.
Enjoy.
Newbs
There is no snooze button on a cat who wants breakfast.