SNTT : Export any Lotus Notes View to Excel from Domino Web, automagically

As an update to Export any Lotus Notes View to CSV or Excel, automagically, and as an answer to a being asked how you would do this, here is some similar code to export a view from the web brower to Excel :

WebExcelPrint.txt

Import it into a Lotus Script Agent, and call it with a url like http://ServerName/YourDatabase.nsf/WebAgentName?OpenAgent&ViewNameToExport

The Initialize routine parse’s the ViewNameToExport off of the Query String, and opens that view object.

The tricky/clever/sneaky part is the :

1
 Print |Content-Type:application/vnd.ms-excel|

which will create and open (if excel is a registed application) the spreadsheet sheet.

You can also do something like this, after that line,:

1
Print |Content-disposition: attachment; filename=| & ViewName & |.xls|

which we let you set the filename of the spreadsheet.

You can also do a bunch more formating of the table cells, and I believe you can pass thur some Excel formulas. (see Microsofts’ Excel Web Connectivity Kit for more details on this.)

See (new father) Jake Howlett’s excelent CodeStore article on Keeping the boss happy for more variations. Enjoy (technorati.com tags :, )

2 Replies to “SNTT : Export any Lotus Notes View to Excel from Domino Web, automagically”

  1. I have found recently that using application/msexcel is a little more forgiving than using application/vsd.ms-excel for Content-Type. The latter one is newer and not always setup on the server.

    Sean—

  2. Caution (at least on my system) if you have a column that contains a multi-value field, you’ll want to @Implode(theField) otherwise this excellent little agent throws up the first time it hits a doc with more than one item in the field.

    Haven’t tried to see if the code can handle the implode so I’m just doing it at the view design level.

Leave a Reply