This and that...

This and that...

Setting up a Domino 8.5 XPages example

Notes ProgramingPosted by Martin Thu, October 01, 2009 12:52:41

In the introduction to XPages in Domino 8.5, a basic downloadable example included is included that displays data from a simple view. In a real application, you would also want to examine individual documents behind a view and possibly modify selected documents. This tip gives you the tools to do this.

To examine the new XPages sample download it from following website and read the previous article for background information on how to install and run any database that contains XPages.

The value of this example is in seeing how this particular code works, while also serving as a test bed for your own experimentation. Install and run this example as is to make sure that it works. Then, you can modify or extend it for your own applications.

To begin, open the new database with Domino Designer and go to the XPages category. You will see two XPages: LaunchPage and Form1Page.

1. LaunchPage is a view-like page that will be displayed when the database is opened with a Web browser.
2. Form1Page is an XPage that acts like a Notes form and shows all fields in a single document.

Double-click on LaunchPage to open it. Within LaunchPage, you'll see some plain text and an embedded view control. Next, follow these steps:

1. Click in the upper-left of the view control to select the entire control.

2. In the lower portion of the screen, select the Properties tab, then the Data sub-tab.

3. This panel controls what data appears in the view control. Note that it references a view in the database named View1.

4. Click on the left-hand column of the view control and look at the Properties/View column. This column displays the plain text value of the data and presents a link to edit the underlying document.

5. Save and close LaunchPage. Be sure to save it under an ID that matches the following security setting:

Go to the server's names.nsf -> Configuration -> Servers -> All Server Documents -> <your-server> -> Security -> Sign agents or XPages to run on behalf of the invoker. Add the name of the person who last saved the XPage. In this example, that will be you.

Double-click on Form1Page and you will see several labels and fields that are similar to those in a standard Notes form. Next, follow these steps:

1. Click outside of the table to select the entire page.

2. In the lower portion of the screen, select the Properties tab, then the Data sub-tab.

Note that the page is bound to the Notes form named Form1 in the current database.


3. Click on each of the three fields in the table. For example, if you look at Properties/Data, you'll see that each is bound to the matching Notes field from Form1.

4. Click on the cell that contains the Submit button – do not click on the button itself. Choose Properties/All Properties below to see the Rendered property. This computed value hides the submit button when the page is opened in read-mode.

5. Save and close Form1Page, making sure to save it under an ID that matches the aforementioned security setting.

Next, look at the database with Lotus Notes 8.5.

1. Open the database, which contains a single view, one form and a short list of documents.

2. Right click on -> Application -> Properties > Launch to examine the launch property of xpages3.nsf. The browser launch is set to use the XPage named LaunchPage.

Run the full sample from a Web browser to see XPages in action.

1. In your Web browser's address bar, enter: http://nnn.nnn.nnn.nnn/xpages3.nsf, where nnn.nnn.nnn.nnn is the IP address or name of your test Domino server.


Notice that xpages3.nsf opens directly to the launch page that you examined and that it displays a view containing the documents of the database.

You can see that the left-hand column of the view contains clickable links. Clicking one should open the underlying document, using the XPage named Form1Page.

You can modify the data in the document then press Submit.


2. After doing so, you may need to use the browser's Back button a couple times to return to the launch page and refresh the page to see the modified data.

Mimic Lotus Notes Domino application functionality on the Web

Notes ProgramingPosted by Martin Fri, March 20, 2009 08:53:50

Lotus Notes Domino developers often want to replicate how applications work within Lotus Notes on an external website. Programmers commonly make extremely large validation and hidewhen routines that place hide and validation logic in the JavaScript header. This can be cumbersome, especially with Lotus Notes forms with hundreds of inputs and tabbed tables.

This "one-size-fits-all" routine performs all of the tasks in bulk -- similar to what Lotus Notes does automatically. The logic then can be encoded directly in the HTML attributes for any input and div tags involved.

This example adds hidewhen attributes to the div tags, but they can also be used with other tags. For the input tags, validation and prompt attributes were added.

Place this in your JavaScript Header:

And put this in your HTML:
The following line is not required: <input type="text" name="example" size="30" /><br> <input type="submit" value="Submit" /> </form> </body>

The challenge we presented ourselves with was to use getElementById instead of document.all in HideWhen() and combine "validation" and "prompt" to one HTML attribute.

10 everyday LotusScript tips

Notes ProgramingPosted by Martin Tue, February 17, 2009 18:51:41

Everyday LotusScript Tip #1. Use error trapping


Error trapping tests a particular condition when running a program. If the program runs into an error, it will then execute a corresponding routine to fix the error. This should always be done. Error handling is not a joke -- it should always be handled in a serious manner and should always be mandatory.

There are two ways to go about this:

Use a single error handler at the top of your LotusScript code. It is simple to implement, but at times difficult to keep in context.

Implement your error handler at the function level. It's a little bit more work, but it's also much more granular.

Everyday LotusScript Tip #2. Use defensive coding


While it may seem a bit paranoid, you should practice using defensive LotusScript coding -- it will save you time in the long run. Always assume the worst and check all inputs on every function. It doesn't usually affect performance, but it is a good failsafe.

Here is a good example of defensive LotusScript coding in a typical function.


Function mytest (p1as String, p2 as String) as integer
mytest = false
if p1 = "" then exit function
if p2 = "" then exit function
. . .
' Now actually do something!
. . . .
mytest = true
end function

Everyday LotusScript Tip #3. Protect your code


When creating commercial applications, it's a very good idea to hide your code. But, you may be asking how. There are actually two ways you can go about it:

Create a template and click on "hide design." This is easy to do, but it may end up allowing form customization.

You could also remove your LotusScript source code from your script libraries. Use the NotesNoteCollection command to find your script design document. Then replace the "$ScriptLib" with a String -- "Hello." This is not the easiest way to go about this process, but your other design elements can be modified as well. (Do not do this on your development copy!)

Everyday LotusScript Tip #4. Use NotesDateTime instead of strings


You should never store date/time values as strings. It is always good practice to use NotesDateTime structures instead and save them.

You might say, sure, but why? Well, you never know how the client will interpret dates. Is it dd/mm/yyyy or mm/dd/yyyy? It also means that views will be able to sort on dates.

Trust me, this is a good tip to practice. This issue comes up more often than you might think.

Everyday LotusScript Tip #5. Use DXL as Transport


A good reason to consider using DXL as Transport stems from a situation where a customer wants to easily send back "log" documents. When this happens, you can use a LotusScript agent to:

Pick up all selected documents.

Create a memo with a rich-text field.

Use DXL to store the documents in the rich-text field.
At the receiving end, this will:

Unpack the mail message to a DXL stream.

Construct new documents to store the data.
This way, you are transferring data without replication. Below is a sample code of this being implemented.


Dim sSession As New NotesSession
Dim dbThis As notesDatabase
Set dbThis = sSession.CurrentDatabase
Dim dc As NotesDocumentCollection
Set dc = dbThis.UnprocessedDocuments
If (dc Is Nothing) Then exit sub
If (dc.count < 1) Then exit sub
Dim doc As NotesDocument
Set doc = dc.GetFirstDocument
While (Not doc Is Nothing)
Dim de As NotesDXLExporter
Set de = sSession.CreateDXLExporter()
Call de.setInput(doc)
Dim dxl As String
dxl = de.Export
' continued overleaf..
Dim dbMail As
New NotesDatabase("", "")
Call dbMail.OpenMail()
Dim docM As NotesDocument
Set docM = dbMail.CreateDocument
Call docM.ReplaceItemValue
("Form", "Memo")
Call docM.ReplaceItemValue
("Recipients", "logs@hadsl.com")
Call docM.ReplaceItemValue
("SendTo", "logs@hadsl.com")
Call docM.ReplaceItemValue
("Subject", "Log Documents")
Dim rt As New NotesRichTextItem
(docM, "Body")
Call rt.AppendText(dxl)
Call docM.Send(False)
Set docM = Nothing
Set de = Nothing
Set doc = dc.GetNextDocument(doc)
Wend

Everyday LotusScript Tip #6. Use a wizard interface in your Notes client


When using a wizard interface with your Lotus Notes client, there are a few steps you should follow:

Create a form with a tabbed table.

Set the tabs to "1," "2," "3," etc.

Select "Switch Rows Programmatically."

Set the "name" field to the name of the table; for example: "RequestTable."

Create a variable on the form with $Name; for example: "$RequestTable."

Have your "forward" and "back" buttons increment/decrement the variable.

Everyday LotusScript Tip #7. Consuming Web services


There are two different ways you can go about consuming Web services. The first is quick and to accomplish it, you should follow these steps:

Install Microsoft SOAP on client machines.

Write LotusScript to create a Microsoft SOAP object. This is a good option because it is quick and handy when it comes to testing. Unfortunately, it is platform-specific, requires dynamic link libraries on clients, and there is no timeout.
Below is some code that illustrates how to create the Microsoft SOAP object.


Dim Client As Variant
Set Client = CreateObject("MSSOAP.SoapClient")
'Initialize connection to the Web Service
Call Client.mssoapinit
("http://localhost/testWS.nsf/Simple?wsdl")
'Call our simple GetEmailAddress
function provided by Web service
Dim result As String
result = Client.getJoke()
'output result to message box
Messagebox result, 48, "Get Joke"

The other approach is a little different. It's big and robust and uses Stubby. Just point it at a Web service and it produces the code for you.

Some good points about it are that it is multi-platform, scalable and there are no dynamic link libraries. However, it does require you to use more than four lines of code.


Everyday LotusScript Tip #8. Use classes


When developing with LotusScript, it is always a good idea to use classes. Here are some reasons why:

Classes help to bundle data and code in one place.

They decompose problems into "objects."

They help to write smaller, more focused code.

They help define and implement the internal data model.

They aid reusability.
Classes have a good design methodology, which leads to Java. But everyone is not used to them and it may take time to sink in. Below you will see some code that implements classes.


Class Person
private nName as NotesName
private strUNID as String
sub new(strNewName as string, strNewUNID asString)
me.nnName = new NotesName(strNewName)
me.strUNID = strNewUNID
end sub
public function getName as String
if (me.nnName is nothing) then exit function
getName = nnName.Canonical
end function
public function getUNID as String
getUNID = strUNID
end function
end class


Everyday LotusScript Tip #9. Use the Evaluate command


The Evaluate command allows you to run @Functions within LotusScript. It is sometimes quicker and easier, as it allows you to use your favorite function in certain situations.

An example of it might be:


evaluate(|@unique|)

Don't overuse it though. Loads of LotusScript functions mimic @functions.


Everyday LotusScript Tip #10. Use "trusted servers"


It is good practice to use trusted servers because scheduled agents cannot normally open databases on other servers.

The "trusted servers" field in a Lotus Domino R6 server document's security section allows servers to trust other servers. By doing this, it allows you to centralize "collection" agents. You also simplify your architecture and limit the number of agents you use. However, it does rely on a fast, reliable network infrastructure.

As a final note, make sure to never trust servers in another domain.

How to import data into Lotus Notes -- without programming

Notes ProgramingPosted by Martin Tue, February 17, 2009 18:46:10

This is the easiest way to import data into Lotus Notes, in my opinion. I have used it many times and it consistently maintains good data fidelity -- meaning that each data item appears in Lotus Notes as you want it to. Date fields come through as proper Lotus Notes dates, numbers as number type, etc. Surprisingly, this technique is based on a product from the Evil Empire and an obsolete file format.

1 Export the data from its current source to Microsoft Excel. Almost every data storage program has some method of exporting data to Excel. Sometimes this feature is built in, as a single button or wizard. If the feature does not appear directly in your source program, you can export the data to a format that Microsoft Excel can read. This can be comma-separated or tab-separated text with fixed-width columns. You then open these files with Microsoft Excel, and are presented with an import wizard that works nicely.

2. Examine and manipulate the data in Microsoft Excel. Make sure you have all the rows (records) and columns (fields) you want. Often the source program exports columns you don't need, so you can just delete those columns completely. You can also delete blank rows, rows that contain garbled data, or data records you don't care about. If your Lotus Notes application contains additional fields, perhaps computed from other columns, you can create those new columns in Microsoft Excel.

3. Insert a top row in the Microsoft Excel spreadsheet that contains the exact names of the Lotus Notes fields for each column of data. Make the row left-justified with a text data format. Do this by selecting the entire row (click on the row number), then pull down Format -> Cells -> Number=Text and Alignment=Left. (If the row is not left-justified, it may not be recognized as a header row later in the process.)

4. Look for columns that appear to be numbers but are actually textual data. The most common are area codes, Zip codes, and customer numbers. You want these fields to be imported to Lotus Notes as text. Storing them as number data within Lotus Notes is incorrect and leads to headaches later. Change these columns to text by selecting the entire column (click on the column name) then pull down Format -> Cells -> Number=Text.

5. Save the finished Microsoft Excel file as a Microsoft Excel Workbook (*.XLS), if it is not already in that format.

6. Save the file again, but this time as a 1-2-3 version 1 spreadsheet. Do this with File -> Save As -> Save As Type = WK1 (1-2-3). Notice that there are other save choices for 1-2-3, such as WK3 and WK1 FMT. Use the one stated here; I have tested it and know that it works. During the save, you will be warned that some features of the spreadsheet may not be compatible with the WK1 file format. Ignore this warning and click "Yes" to continue the save.

7. Close the Microsoft Excel sheet. You will be asked if you want to save the changes you made to <filename>.WK1. This time, answer "No." You already have two copies of the sheet -- one in .XLS and one in WK1. If you answer "Yes" here, you may overwrite your .XLS file.

8. Start Lotus Notes. Open the database where you want to import the data.

9. Use the Lotus Notes command File -> Import. Select the WK1 file you just created. The import type will automatically change to Lotus 1-2-3.

10. Press the Import button.

11. Set the options: Import As = Main Document, Using Form = <your form>, Column Format = Defined by the WKS Title, Limit What is Imported = <blank>, Calculate Fields on Form = <disabled>.

12 Press OK.

This method may appear long-winded, but it is really quite easy. After using it a couple times, you can import almost any data from almost any source very quickly.

Warning: There is a hard limit of 8,192 rows for 1-2-3 version WK1 spreadsheets. You have a header row, so this leaves 8,191 rows for data. If you exceed this limit, Microsoft Excel will simply cut off output to the WK1 after 8,192 lines -- without telling you. I have made this mistake, and luckily noticed the error before my customer did.

And, just to clarify, you do not need the 1-2-3 software at all. You are just using the old 1-2-3 file format for the data exchange.

This method allows for extra control of the import process and works for up to 65,000 records. The key idea is that you use a small control file (.COL) that tells Lotus Notes how to import a tab-separated text file.


1. Export the data from its current source to Microsoft Excel. Almost every data storage program has some method of exporting data to Excel. Sometimes this feature is built in, as a single button or wizard. If the feature does not appear directly in your source program, you can export the data to a format that Microsoft Excel can read. This can be comma-separated or tab-separated text with fixed-width columns. You then open these files with Microsoft Excel, and are presented with an import wizard that works nicely.

2. Examine and manipulate the data in Microsoft Excel. Make sure you have all the rows (records) and columns (fields) you want. Often the source program exports columns you don't need, so you can just delete those columns completely. You can also delete blank rows, rows that contain garbled data, or data records you don't care about. If your Lotus Notes application contains additional fields, perhaps computed from other columns, you can create those new columns in Microsoft Excel.

3. Insert a top row in the Microsoft Excel spreadsheet that contains the names of the Lotus Notes fields for each column of data. You will not really use this header row during the import, but it will be helpful to have it later to remind yourself what you did.

4. Look for columns that appear to be numbers but are actually textual data. The most common are area codes, Zip codes, and customer numbers. You want these fields to be imported to Lotus Notes as text. Storing them as number data within Lotus Notes is incorrect and leads to headaches later. Change these columns to text by selecting the entire column (click on the column name) then pull down Format -> Cells -> Number=Text.

5. Save the finished Excel file as an Excel Workbook (*.XLS), if it is not already in this format.

6. Save the file again, but this time as a tab-delimited text file. Do this with File -> Save As -> Save As Type = Text (Tab Delimited). During the save, you will be warned that some features of the Excel spreadsheet may not be compatible with text format. Ignore this warning and click "Yes" to continue the save.

7. Close the Microsoft Excel spreadsheet. You will be asked if you want to save the changes you made to <filename>.TXT. This time, answer "No." You already have two copies of the sheet -- one in .XLS and one in .TXT.

8. Create a column description file that tells Lotus Notes the format of the .TXT file. Column files have a .COL extension and are created with a plain-text editor, such as Notepad. An example is below.

9. Start Lotus Notes. Open the database where you want to import the data.

10. Use the Lotus Notes command File -> Import. Select the .TXT file you created from Microsoft Excel. The import type will automatically change to Tabular Text.

11. Press the Import button.

12. Set the options: Import As = Main Document, Using Form = <your form>, Use Format File = Enabled, Format File = <your format>.COL, Header Line Count = 1, Footer = 0, Line Per Page = 0, Calculate Fields on Form = Disabled.

13 Press OK.

Again, this looks harder than it is. After creating a few .COL files, you can copy/modify them from previous jobs.

Example .COL file for importing tab-delimited text into Lotus Notes:

;Comment line.
CaseNumber: TYPE TEXT UNTIL "<tab>";
SlipDate: TYPE DATETIME UNTIL "<tab>";
SlipHours: TYPE NUMBER UNTIL "<tab>";
BillingCode: TYPE TEXT UNTIL "";

Notice that each line states the data type of the field. Where you see <tab> in the example, enter a real TAB character, by pressing the TAB key as you create the .COL file.

Warning: Look carefully in the .TXT file to make sure each line ends immediately after the last field of data. Sometimes, Microsoft Excel thinks there are empty columns and inserts extra tab characters to the right of your data in each row. If your file contains these extra tabs, just change the last field definition in the .COL file from null string to <tab>.

How to import an unlimited number of data records into Lotus Notes

With the method I explained in Part 2, the limit of 65,000 records is imposed by Microsoft Excel, rather than Lotus Notes. So if you skip the Microsoft Excel step, there is effectively no limit on the number of records you can import to Lotus Notes from a .TXT file. I have tested 175,000 records.

For imports greater than 65,000 records, simply create a tab-separated .TXT file directly from your source program, and then perform the import to Lotus Notes as described in Part 2.

If your source program cannot create tab-separated output, you might try a different separator, such as vertical bar (|). Just edit the .COL file and replace <tab> with the new separator.

When you go directly from the source program to a .TXT file, you miss the opportunity to examine and clean the data with Microsoft Excel. But this may be necessary in order to perform very large imports.

You can write some simple @-function agents later within Lotus Notes to fix data problems when the import is finished. You can even put the @-functions directly into the .COL file.

For advanced tricks that you can do with a .COL file, such as @-function post-processing of imported data, see Domino Designer Help -> Index -> COL Files.


Importing data from Microsoft Excel to a Lotus Notes form

Notes ProgramingPosted by Martin Tue, February 17, 2009 18:34:17

Below is a sample shell of code to get a handle to an Excel file, and read values in the first column. You could adapt it to build an array of values in the first column, and set that value on a user profile document or hidden field on your form. You could then reference that profile or hidden field as the formula for the dialog list.

Use following code:

The next step is reading the rest of the row. After the dialog list value is selected, another script would need to run to look for the selected value in the Excel row and read the rest of the columns in the row.

The cleanest way to do this would probably be to pop up a separate form to let the user choose the SWO#, and then trigger the second script when the prompt form is closed.

You have to be careful about dealing with Excel objects this frequently though, because they are locked while the object is open. This may cause a problem if multiple users are trying to access the same Excel file on a shared drive.

In my opinion, it is a better idea to write a script to import all of the Excel rows into Lotus Notes (one document per row) on a scheduled basis, and use Lotus Notes formulas for the dialog list and subsequent row values. This will perform better and allow it to work for multiple users concurrently.

How to import data from Microsoft Excel to a Lotus Notes form with LotusScript

Notes ProgramingPosted by Martin Tue, February 17, 2009 18:29:24

Here is what I feel is the simplest and quickest LotusScript code to import data from Microsoft Excel to a Lotus Notes form. Make sure that the first row of your Microsoft Excel spreadsheet has the field names from the Lotus Notes form that you'd like to use for the import.

To implement this LotusScript code:

Insert the LotusScript below into an action button in a view, or make it available from the action menu, because it uses the NotesUIWorkspace class.

Write the code in an agent and run it from the Actions menu. This will import up to 256 columns by 65,536 rows from Excel to your Lotus Notes form.

Use following code:



Secure Microsoft Excel spreadsheets with LotusScript

Notes ProgramingPosted by Martin Tue, February 17, 2009 18:26:14

Want to protect Microsoft Excel spreadsheets from tampering? This LotusScript code only allows users to edit columns that you specify as permitted. Other columns can be locked programmatically, and the Microsoft Excel file will be protected with a password. The only way for the secured columns to be edited is for the user to know the password and edit them after entering it.

'Setting the Excel object.

Set ExcelApp = CreateObject("Excel.Application")
Set ExcelWorkbook =
ExcelApp.Workbooks.Open("C:TempTest.xls")
Set ExcelWorksheet =
ExcelWorkbook.Application.Workbooks(1).Worksheets(1)
' You can enter the values and once
the entry is over lock the columns.
With ExcelWorksheet
' .Range("A1:B1").Select
.Range("A1").Value ="Prasad"
.Range("B1").Value ="Lekshmi"
.Range("A1:B1").Locked=True
.Range("A2:A10").Locked=False
End With
ExcelWorksheet.Protect Password="1234"
' You just need one line to protect excel sheet from tampering.
ExcelWorkbook.Save
ExcelApp.quit
Set ExcelApp=Nothing

How to export Lotus Notes views to a Microsoft Excel database

Notes ProgramingPosted by Martin Tue, February 17, 2009 18:18:31

Exporting data from a Lotus Notes view to a Microsoft Excel database is a simple process that doesn't require object linking and embedding (OLE) and is easily customizable. To begin, create a LotusScript agent that will retrieve all data from a Lotus Notes view and export it to Microsoft Excel. Lotus Notes users can then format the Excel spreadsheet to their specifications for reporting purposes.

This process requires a single LotusScript agent and one shared action to call it. Place the shared action in the Lotus Notes view that you want to export. The trick is to write a text file using HTML table formatting and save the file with a Microsoft Excel extension (.XLS). Next, you can send email messages to Lotus Notes users that include their reports.

When a user opens the file, Microsoft Windows will open Excel. The program then detects that the file is an HTML table and imports it into Microsoft Excel using the specified HTML formatting.

Sub Initialize

'I placed all of the code in a single sub

(normally I split it all out... but for this demo

purpose, I just put all code in one sub)

Dim doc As NotesDocument

Dim uidoc As NotesUIDocument

Dim tmpdir As String

Dim uiview As NotesUIView

Dim view As NotesView

Dim dc As NotesDocumentCollection

Dim ret As Integer

Dim session As NotesSession

Dim db As NotesDatabase

Dim workspace As NotesUIWorkspace

Dim tmpdatafilename As String

Dim tmpdatafilenumber As Integer

Dim memodoc As NotesDocument

Dim rtitem As NotesRichTextItem

Dim object As NotesEmbeddedObject

Set session = New NotesSession

Set workspace = New NotesUIWorkspace

Set db = session.CurrentDatabase

tmpdir = session.GetEnvironmentString

("Directory", True)

tmpdatafilenumber% = Freefile()

tmpdatafilename = tmpdir & "HRReport.xls"

'Open a file for output

Open tmpdatafilename For Output As

tmpdatafilenumber

Set uiview = workspace.CurrentView

Set view = uiview.View

'Print to the file some basic CSS for easy

formatting later if the users want a change

to the default.

Print # tmpdatafilenumber%, |

<HTML>

<HEAD>

<TITLE>Table example</TITLE>

<STYLE type="text/css">

TABLE { background: #ffffff; border: solid black;

empty-cells: hide }

TD { border: solid black;

border-left: none;

border-right: none;

}

TD.top { border: solid black;

border-left: none;

border-right: none;

background: #C0C0C0;

font-weight: bold;

font-size: 11px;

text-align: center;

}

TD.viewname { border: solid black;

border-left: none;

border-right: none;

border-bottom: none;

background: #C0C0C0;

font-weight: bold;

font-size: 16px;

text-align: left;

}

TD.salary { border: solid black;

border-left: none;

border-right: none;

background: #00FFFF;

}

</STYLE>

</HEAD>

<BODY>|

'Heart of the code....

'Print an HTML Table and then construct

the table from the column contents

of the current view.

Print # tmpdatafilenumber%, |<table>|

'Include the view name in the top of the

spreadsheet

Print # tmpdatafilenumber%, |<tr>|

Print # tmpdatafilenumber%,

|<td class="viewname"

colspan="| & Cstr((Ubound(view.Columns) + 1))

& |">|

Print # tmpdatafilenumber%, view.Name

Print # tmpdatafilenumber%, |</td>|

Print # tmpdatafilenumber%, |</tr>|

'Start a row of headers (couldn't get TH CSS to work,

so I created my own class called top)

Print # tmpdatafilenumber%, |<tr>|

Forall vc In view.Columns

Print # tmpdatafilenumber%, |<td class="top">|

Print # tmpdatafilenumber%, vc.title

Print # tmpdatafilenumber%, |</td>|

End Forall

Print # tmpdatafilenumber%, |</tr>|

'Now loop though all of the documents in the

view and create a HTML for each one.

'For each column, put in the cell tag.

Set doc = view.GetFirstDocument

Do While Not doc Is Nothing

Print # tmpdatafilenumber%, |<tr>|

Forall c In doc.ColumnValues

Print # tmpdatafilenumber%, |<td>|

If Isarray(c) Then 'Make sure you work with a

multivalued field.

For a = 0 To Ubound(c)

If a = 0 Then

Print # tmpdatafilenumber%, c(a)

Else

Print # tmpdatafilenumber%, "<br>" & c(a)

End If

Next

Print # tmpdatafilenumber%, |</td>|

Else

Print # tmpdatafilenumber%, c

End If

Print # tmpdatafilenumber%, |</td>|

End Forall

Print # tmpdatafilenumber%, |</tr>|

Set doc = view.GetNextDocument(doc)

Loop

'Now that you have all of your data, end the

table and html tags

Print # tmpdatafilenumber%, |</table>|

Print # tmpdatafilenumber%, |</body>|

Print # tmpdatafilenumber%, |</html>|

Close tmpdatafilenumber%

'Now you can either prompt them for where the

report is on their hard drive, or you can

email it to them

'If like email....

Set memodoc = db.CreateDocument

memodoc.Form = "Memo"

memodoc.Subject = "Exported View Report"

Set rtitem = New NotesRichTextItem

(memodoc, "Body")

Call rtitem.AppendText(memodoc.Subject(0))

Call rtitem.AppendText(Chr$(10) & Chr$(10))

Call rtitem.AppendText("Open the attached file

in Excel to view the report.")

Call rtitem.AppendText(Chr$(10) & Chr$(10))

Set object = rtitem.EmbedObject _

( EMBED_ATTACHMENT, "", tmpdatafilename)

memodoc.SendTo = session.UserName

Call memodoc.Send(False)

Kill tmpdatafilename ' Delete the file from the

users hard drive if you email the report.

Messagebox "Please check your inbox for the

report", 0 + 64, "Report Complete"

End Sub

Next »