Allt om Lotus Notes & Domino

Read values from a CSV file attached to a Document and present it in XPages
This simple server side javascript code read the content of a file stored in a rich text field
Read a csv file attached to a notes document and present it in Xpages without detaching the file to disc

This is what the attached CSV file looks like

and so on...

Step #1. Make sure you have an attachment in the first document, in the body field in a view call "Main"
Step #2. Put the following code in a link control in a new xpages


var eo:NotesEmbeddedObject = null;

// Get the first document in the main view
var doc:NotesDocument = database.getView("Main").getFirstDocument()
var rt = doc.getFirstItem("Body")

// get the attachment in Body field
var v:java.util.Vector = rt.getEmbeddedObjects();
var it:java.util.Iterator = v.iterator();

// Create a new HashMap/TreeMap to store each line in
// TreeMap is better if you want the values sorted

//var hm:java.util.HashMap = new java.util.HashMap();
var hm:java.util.TreeMap = new java.util.TreeMap()
var c=0;

// Loop all attachments in body field
while (it.hasNext()) {
eo =;

// Read the stream from the attachment
var br = new;
var strLine = "";

// Read each line in the csv file
while ((strLine = br.readLine()) != null) {

// put each line in the TreeMap
hm.put("Row " + c,strLine)

// return the TreeMap to the repeat control = hm


Step #3. Add the following repeat control code to the xpage

<xp:repeat id="repeat1" rows="30" var="entry">
<xp:this.value><![CDATA[#{javascript:var m =
<xp:panel tagName="DIV">
<xp:text escape="true" id="computedField1" value="#{javascript:entry.getValue()}"></xp:text>

Image below show what it looks like in the browser, each line in the csv file represent one entry in the repeat

If you only want the second value you can tweak the "entry" value like this

<xp:repeat id="repeat1" rows="30" var="entry">
<xp:this.value><![CDATA[#{javascript:var m =
<xp:panel tagName="DIV">
<xp:text escape="true" id="computedField1"><xp:this.value><![CDATA[#{javascript:@Word(entry.getValue(),";",2)}]]></xp:this.value></xp:text>

Image below show what only the second value

Many thanks to Paul Withers and Mark Leusink for their support

Relevanta Poster på Notessidan:

Fler Poster om:

Fler bloggar om:


Publicerad 2014-03-28 | Kommentarer: 3 | Läsningar:


David Leedy ( 2014-03-29 00:18:16 )

Thomas Adrian ( 2014-03-31 08:19:38 )

Stephan H. Wissel ( 2014-04-01 09:36:43 )

Sök på Notessidan
Thomas Adrian
ThomasCertifierad utvecklare och administratör inom Notes & Domino

Kontakta mig

Senaste Sökningarna på Notessidan
Sön - sharepoint (R:1)
Sön - räkna and antal and besökare (R:0)
Sön - browser (R:17)
Sön - stoppar and mail (R:1)
Sön - korrupt (R:3)
Sön - böcker (R:0)
Sön - kalendern (R:12)
Sön - feature (R:15)
Sön - print and mime (R:2)
Sön - länka (R:0)
Sön - databasen (R:94)
Sön - access (R:47)
Sön - outlook (R:15)
Sön - webanvändare (R:0)
Sön - google and maps (R:6)
Sön - juffe (R:2)
Sön - uidoc.print (R:1)
Sön - java and lotusscript (R:26)
Sön - besök (R:0)

Databasstatistik Blogg
Uppdateras var 15:e Minut

Antal Poster:562
Antal Kommentarer: 1449
Alla sidvisningar idag:
Unika Besökare idag:
Databasstorlek: 142,25Mb
Fixup: 2020-03-30 00:31:05
FT:2020-03-31 12:58:52
DB Procent använd: 99,7
Antal Agenter: 42
Antal Formulär: 65
Antal Vyer: 60
Antal Dokument: 8133
Antal Image Resources: 108
Antal Subformulär: 18
Antal Scriptbibliotek: 11
Totalt Antal Designelement: 576
Antal Attachments: 158
Antal Konflikter: 0
Server version 1: 405
Server version 2: Release 9.0.1FP9|August 14, 2017
Server Plattform: Windows/64
Ändrad: 2020-03-31 16:26:52
Server Tidszon: Z=-1$DO=1$DL=3 -1 1 10 -1 1$ZX=131$ZN=W. Europe
Kommentarsspam Idag: 1
Kommentarsspam Totalt: 20853

Top Sites at

Fight Spam! Click Here!

Listed on BlogShares

Increase website traffic

Top Internet Blogs

Site Checker