Sub createExcel(title As String ,dc As NotesDocumentCollection,description() As String,fieldName() As String)
'***************************************************************************
'title 表名 dc文件集 descripton 栏位描述 fieldname栏位名
'生成excel 報表
'***************************************************************************
Dim rdoc As NotesDocument
Dim ritem As NotesItem
Dim xlApp As Variant
Dim xlsheet As Variant
Dim t As String
Dim j As Integer
Dim row As Integer
Dim col As Integer
Dim s As Integer
Dim maxNO As Integer
Dim tmp As Integer
col=Ubound(description)
Set xlApp = CreateObject("Excel.application")
xlApp.Workbooks.Add
Set xlsheet = xlApp.Workbooks(1).Worksheets(1)
XlApp.Windows(1).DisplayGridlines=True
xlsheet.Activate
xlsheet.Visible=1
xlApp.Visible=True
xlsheet.name=title
xlApp.Range("A1:"+Chr$(col+64)+"2").Select
With xlApp.Selection
'.HorizontalAlignment = xlCenter
'.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
'.ReadingOrder = xlContext
.MergeCells = True
End With
xlsheet.Range("A1").value=title
Set rdoc=dc.GetFirstDocument
count=dc.Count
i=4
For j=65 To col+64
xlsheet.Range(Chr$(j)+"3")=description(j-65)
Next
While Not rdoc Is Nothing
tmp=1
For j=65 To col+64
Set ritem=rdoc.GetFirstItem(fieldname(j-65))
If Not ritem Is Nothing Then
s=i
maxNO=0
//多值栏位拆解
Forall o In ritem.Values
xlsheet.Range(Chr$(j)+Cstr(s)).value=o
s=s+1
maxNO=maxNO+1
If maxNO>tmp Then
tmp=maxNO
End If
End Forall
Else
xlsheet.Range(Chr$(j)+Cstr(i)).value=""
End If
Next
Set rdoc=dc.GetNextDocument(rdoc)
i=i+tmp
Wend
End Sub