PermaLink Quick approach to creating Excel Output for browser users03/09/2006 09:33 AM
Category : Show-n-Tell Thursday
Location : Columbus, Ohio, USA
Technorati tags: , ,

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.

This page has been accessed 685 times. .
Comments :v

No documents found

Post a comment ^


Email addresses provided are not made available on this site.





You can use UUB Code in your posts.

[b]bold[/b]  [i]italic[/i]  [u]underline[/u]  [s]strikethrough[/s]

URL's will be automatically converted to Links


:-x :cry: :laugh: :cool: :-( :huh: :rolleyes: :grin: :-p :angry: :-D ;-) :-) :-\ :lips: :emb: :-o
bold italic underline Strikethrough





Remember me    

Add Manual Trackback
Please enter the details of the trackback post. Your trackback will not appear on the site until it has been verified. This won't be immediate, as trackbacks are validated on a scheduled basis. Be patient.











Useful Links
Contact Me
Calendar
February 2012
Su
Mo
Tu
We
Th
Fr
Sa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Planet Lotus
By Category
The BlogRoll
Monthly Archive
Lotus Domino ND6 RSS News Feed RSS Comments Feed RSS Validator Blog Admin Lotus Geek Open Notes Picture Database OpenNTF CoComment Integrated BlogSphere
Powered by
Blogsphere