Export an Excel table and Word document from Notes view

xiaoxiao2021-03-06  64

Code:

% Include "lsconst.lss"% include "lsxbeerr.lss"

Sub Initialize Dim session As New NotesSession Dim db As NotesDatabase Dim v As NotesView Dim docX As NotesDocument Dim col As Integer Dim lineitem As String Dim View As String Set db = session.CurrentDatabase Print | Content-Type: application / vnd.ms-excel ; Charset = GB2312 | Print | Content-Disposition: attachment; filename = "report.xls" | 'on error goto errorhandler view = "$ attachmentView"' Here, the conversion view name set v = db.getView (view $) Call v.refresh col = 1 Print || Print |

| lineItem = "" FORALL VCOLUMN in v.columns if color = 1 Then LineItem = | < Font color = # 0000FF size = 3> | vColumn.title else lineItem = lineItem | | vcolumn.title End if col = col 1 End Forall lineitem = lineitem Print lineitem Set docX = v.GetFirstDocument lineitem = "" While Not docX Is Nothing col = 1 Forall cValue In docX.ColumnValues ​​If col = 1 Then lineitem = | | End If If CValue = "" "THEN LINEITEM = LineItem |
| Elseif Isdate (CVALUE) THEN LINEITEM = LineItem | | CVALUE ||
elseif isnumeric (CVALUE) Then IF (v.columns (color) .Numberformat = 3) Then lineItem = lineItem | | CVALUE || Else LineItem = lineItem |
| CVALUE ||

END IF ELSE LINEITEM = lineItem |

| CVALUE || End if Col = col 1 End FORALL PRINT LINEITEM || SET DOCX = V.GetnextDocument (DOCX) Wend Print | | EXIT Sub Errorhandler: Print "Agent Runtime Error" & Err () & ":" & Error () & "- The line number is:" CSTR (ERL) & chR $ (13) EXIT SUB END SUB is more than specified a view First, the list is sequentially read, and then the record is sequentially read, print it out. Select different protocols, such as "Print | Content-Type: Application / Vnd.ms-Excel; Charset = GB2312 |", Print Excel Document, "Print | Content-Type: Application / VND.MS-Word; Charset = GB2312 | ", Print the Word document. Other corresponding places in the agent should also be changed.

Perform improvement: You can read a config file first by let the agent first specify the name of the nice view, the name of the column that can be exported and the serial number in the view, which first selects the selection through a selection page and then exported.

转载请注明原文地址:https://www.9cbs.com/read-119455.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.028, SQL: 9