LotusScript programming of an Excel file

zhaozj2021-02-16  95

DIM session as new notessession

DIM DB AS NotesDatabaseDoase

DIM View As Notesview

DIM DOC AS NotesDocument. NBSP

DIM Excelapplication As Variant

DIM Excelworkbook as variant

Dim Excelsheet As Variant

DIM I as integer

DIM MOOD AS STRING

DIM Selection As Variant

ON Error Goto Err1

SET Excelapplication = CreateObject ("excel.application")

SET Excelworkbook = Excelapplication.workbooks.add

SET EXCELSHEET = Excelworkbook.worksheets ("sheet1")

'Define the column value of Excel

Excelsheet.cells (1, 1) .value = "Sequence"

Excelsheet.cells (1, 2) .value = "Project Code"

Excelsheet.cells (1, 3) .value = "Project Model"

Excelsheet.cells (1, 4) .value = "Project Description"

Excelsheet.cells (1,5) .value = "Maintenance person"

Excelsheet.cells (1,6) .value = "Remarks"

i = 1

Set db = session.currentDatabase

'Get View

Set view = db.getView ("Project List")

SET DOC = view.getfirstdocument. NBSP

While Not (Doc is Nothing)

i = i 1

'Define the domain name

Excelsheet.cells (i, 1) .value = i-1

Excelsheet.cells (i, 2) .value = DOC.P_CODE (0)

Excelsheet.cells (i, 3) .value = DOC.P_NAME (0)

Excelsheet.cells (i, 4) .value = DOC.P_DESC (0)

Print "Lead" & I & "record successfully, please wait!"

Set doc = view.getnextdocument. DOC)

Wend

Excelworkbook.saveas ("C: / Project List .xls")

"The report is successful, please find it to the root directory of the C drive!", 48, "Tips"

Excelapplication.quit

Set excelapplication = Nothing

EXIT SUB

Err1:

"Msgbox" error, please contact your administrator! ", 48," Tips "

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

New Post(0)