Domino general view printing (using Excel print)

zhaozj2021-02-12  157

Sub initialize

DIM session as new notessession

DIM DB AS NotesDatabaseDoase

Set db = session.currentDatabase

DIM View As Notesview

Set view = db.getView ("printview")

ipageline = int (INPUTBOX ("number per page?"))

DIM Excelapplication As Variant

DIM Excelworkbook as variant

Dim Excelsheet As Variant

SET Excelapplication = CreateObject ("excel.application")

Excelapplication.visible = TRUE

SET Excelworkbook = Excelapplication.workbooks.add

SET EXCELSHEET = Excelworkbook.worksheets ("sheet1")

REM output

'Set high

Excelsheet.Rows.RowHeight = 40

'carry out

'Vertical

Excelsheet.Rows.VerticalALIGNMENT = 2

'carry out

DIM Navigator as NotesViewNavigator

DIM Entry As NotesviewEntry

Set navigator = view.createViewnav ()

Set entry = navigator.getfirst

i = 0

Do While (not entry is nothing)

IF i mod ipageline = 0 Then '10 Route [A4]

IF i <> 0 THEN

J = 1

FORALL ColumnValue in entry.columnvalues

Excelsheet.cells (i, j) = columnValue

J = J 1

End forall

Set entry = navigator.getnext (entry)

END IF

Excelsheet.Range (CSTR (i 1) ":" CSTR (i 1)). font.size = 18

Excelsheet.Range (CSTR (i 1) ":" CSTR (i 1)). Border.weight = 1

Excelsheet.Rows (i 1) .rtowheight = 60

Excelsheet.Range ("a" CSTR (i 1) ":" "E" CSTR (i 1)). MERGE (TRUE) 'merged cell

Excelsheet.Range ("a" CSTR (i 1) ":" "E" CSTR (i 1)). Mergecells = true 'merge unit

Excelsheet.cells (i 1, 1) = "Report Name"

Excelsheet.cells (i 1, 1). Horizontalalignment = 3

Excelsheet.cells (i 1, 1) .verticalAlignment = 3

K = 1

FORALL M in View.columns

Excelsheet.cells (i 2, k) = m.titleExcelsheet.cells (i 2, k). Horizontalalignment = 3

K = K 1

End forall

i = i 3

Else

J = 1

FORALL ColumnValue in entry.columnvalues

Excelsheet.cells (i, j) = columnValue

'Setting the column width

Excelsheet.columns (j) .columnwidth = 20

'carry out

J = J 1

End forall

Set entry = navigator.getnext (entry)

i = i 1

END IF

Loop

i = i-1

IF i mod ipagelineline <> 0 THEN

Fork = 1 to ipageline- (i mod ipagelineline)

Excelsheet.cells (i k, 1) = ""

NEXT

END IF

REM output

Excelsheet.usedRange.select

'Excelsheet.usedRange.ntireColumn.autofit

Excelsheet.UsedRange.wrapText = TRUE

Excelsheet.UsedRange.Borders.weight = 2

Excelsheet.usedRange.VerticalAlignment = 3

'Excelsheet.UsedRange.horizontalalignment = 4' horizontal right alignment

Excelworkbook.PersonAlViewPrintSettings = true 'cells Chinese automatic wrap

Excelworkbook.printpreview

Rem Excelworkbook.printout

Excelapplication.quit

SET EXCELSHEET = Nothing

End Sub

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

New Post(0)