Notes Ninjas Notes Ninjas
Lotus Notes hints, tips, error messages
Export to Excel from Web Browser

Hint Short Cut: Add this to your code & documentation to help you find this page.
http://www.notesninjas.com/#WebExcelExport or http://www.notesninjas.com/A555F9/nn.nsf/ByAlias/WebExcelExport


Customer required printing and exporting of selected documents from web search results to Excel. Fortunately the existing database had excel export code already in, I adapted it to work with selected search results.





Create a lotusscript agent that is called with the view and selected documents.

The secret to export to excel is this line:

Print "Content-Type:application/vnd.ms-excel"

 

'Then you need to start to define the columns and data:
Print "<HTML><HEAD><TITLE>Excel from Web</TITLE></HEAD><BODY><TABLE>"

'Optionally put in some CSS code to format the headings nice:

print|<style>|
print|.style0 {|
print|    text-align:general;|
print|    vertical-align:bottom;|
print|    border-bottom: 1px solid black;|
print|    font-weight: bold;|
print|    color: #000000;|
print|    background: #A0A0A0;|
print|}|
print|.style1 {|
print|    border-bottom: 1px dotted gray;|
print|    border-left: 1px dotted gray;|
print|    border-right: 1px dotted gray;|
print|}|
print|</style>|

'Put the headings in

print |<TR>|

print |<TD class='style0'>Heading 1</TD>|

print |<TD class='style0'>Heading 2</TD>|

print |</TR>|

'Then put in your data lines ' maybe using a loop

print |<TR>|

print |<TD class='style1'>Row 1 Col1</TD>|

print |<TD class='style1'>Row 1 Col2</TD>|

print |</TR>|

print |<TR>|

print |<TD class='style1'>Row 2 Col1</TD>|

print |<TD class='style1'>Row 2 Col2</TD>|

print |</TR>|

'Then finish off

Print "</TABLE></BODY></HTML>"

 

Nice an easy.

 

Of course this might work with Open Office as well.

If you have the vnd description you can use that to change it to Open Office.

For people wothout excel, you can output the data as Content-type: text/csv

Another option is to end the agent's url with the text file type eg: http://server/db.nsf/agent?open&.csv or .xls

I do this with RSS and it works well.  &.xml

 

 

 Jump to:     Notes Tips
    Lotus Notes Index 
  Register for Tips
Previous Lotus Notes Tip 
    Next Lotus Notes Tip
Your company logo here?
Adam Foster
Free Cash Making Web Site
Free Revenue Earning Blog Site
 Free Revenue Earning Newsletter Site   
Free Search Pages Free Web stats
Free Contact Us page
Cheap .com domain names
 Need a website or 
   Lotus Notes
  problem solved?
Adam Foster
Lotus Notes and Domino 6 Programming Bible by Brian Benz, Rocky Oliver
Covers all the programming techniques, concepts, and languages used with Notes and Domino, as well as the many new features of Domino 6 Thoroughly examines the Notes and Domino role with Java, XML, Web services, and other IBM products and technologies Provides extensive code and examples, many geared to the needs of administrators High-profile authors, known to their audience through conferences and articles Companion Web site shows example applications from the book running on a live Domino server and provides code download.
See at: Amazon.co.uk | Amazon.com |