Sub Initialize
On Error Goto er
Dim session As New NotesSession
Dim dbname As NotesDatabase
Dim view As NotesView
Dim ryzzdoc As NotesDocument
Set dbname = session.CurrentDatabase
Print |<script>|
Print |var xls = new ActiveXObject ( "Excel.Application" );
xls.visible =true; //设置excel为可见
var xlBook = xls.Workbooks.Add;
var xlsheet = xlBook.Worksheets(1);
<!--合并-->
xlsheet.Range(xlsheet.Cells(1,1),xlsheet.Cells(1,5)).mergecells=true;
xlsheet.Range(xlsheet.Cells(1,1),xlsheet.Cells(1,5)).value="人员信息采样表";
<!--设置行高-->
xlsheet.Rows(1).RowHeight = 25;
xlsheet.Rows(1).Font.Size=14;
xlsheet.Rows(1).Font.Name="黑体";
<!--设置显示字符而不是数字-->
//设置单元格内容自动换行 range.WrapText = true ;
//设置标题栏
xlsheet.Cells(2,1).Value="公司名称";
xlsheet.Cells(2,2).Value="部门名称";
xlsheet.Cells(2,3).Value="科室名称";
xlsheet.Cells(2,4).Value="员工名称";
xlsheet.Cells(2,5).Value="职务";|
Dim i As Integer
i=3
Set view = dbname.GetView("OrgaAndPersonByReponse")
Set ryzzdoc = view.GetFirstDocument
While Not ryzzdoc Is Nothing
If ryzzdoc.jibie(0) = "1" Then
Print |xlsheet.Cells(|+Cstr(i)+|,1).Value="|+ryzzdoc.GSmc(0)+|";|
i=i+1
If ryzzdoc.JGleader(0) <> "" Then
Print |xlsheet.Cells(|+Cstr(i)+|,2).Value="|+Strleft(ryzzdoc.JGleader(0),"/")+|";|
Print |xlsheet.Cells(|+Cstr(i)+|,5).Value="公司领导";|
i=i+1
End If
If ryzzdoc.JGleader_S(0) <> "" Then
For k = Lbound(ryzzdoc.JGleader_S) To Ubound(ryzzdoc.JGleader_S)
Print |xlsheet.Cells(|+Cstr(i)+|,2).Value="|+Strleft(ryzzdoc.JGleader_S(k),"/")+|";|
Print |xlsheet.Cells(|+Cstr(i)+|,5).Value="公司副领导";|
i=i+1
Next
End If
Else
If ryzzdoc.jibie(0) = "2" Then
Print |xlsheet.Cells(|+Cstr(i)+|,2).Value="|+ryzzdoc.JGmc(0)+|";|
i=i+1
If ryzzdoc.JGleader(0) <> "" Then
Print |xlsheet.Cells(|+Cstr(i)+|,3).Value="|+Strleft(ryzzdoc.JGleader(0),"/")+|";|
Print |xlsheet.Cells(|+Cstr(i)+|,5).Value="部门领导";|
i=i+1
End If
If ryzzdoc.JGleader_S(0) <> "" Then
For k = Lbound(ryzzdoc.JGleader_S) To Ubound(ryzzdoc.JGleader_S)
Print |xlsheet.Cells(|+Cstr(i)+|,3).Value="|+Strleft(ryzzdoc.JGleader_S(k),"/")+|";|
Print |xlsheet.Cells(|+Cstr(i)+|,5).Value="部门副领导";|
i=i+1
Next
End If
If ryzzdoc.member(0)<> "" Then
For k = Lbound(ryzzdoc.member) To Ubound(ryzzdoc.member)
Print |xlsheet.Cells(|+Cstr(i)+|,4).Value="|+Strleft(ryzzdoc.member(k),"/")+|";|
Print |xlsheet.Cells(|+Cstr(i)+|,5).Value="部门员工";|
i=i+1
Next
End If
Else
If ryzzdoc.jibie(0)="3" Then
Print |xlsheet.Cells(|+Cstr(i)+|,3).Value="|+ryzzdoc.JGmc(0)+|";|
i=i+1
If ryzzdoc.JGleader(0) <> "" Then
Print |xlsheet.Cells(|+Cstr(i)+|,4).Value="|+Strleft(ryzzdoc.JGleader(0),"/")+|";|
Print |xlsheet.Cells(|+Cstr(i)+|,5).Value="科室领导";|
i=i+1
End If
If ryzzdoc.JGleader_S(0) <> "" Then
For k = Lbound(ryzzdoc.JGleader_S) To Ubound(ryzzdoc.JGleader_S)
Print |xlsheet.Cells(|+Cstr(i)+|,4).Value="|+Strleft(ryzzdoc.JGleader_S(k),"/")+|";|
Print |xlsheet.Cells(|+Cstr(i)+|,5).Value="科室副领导";|
i=i+1
Next
End If
If ryzzdoc.member(0)<> "" Then
For k = Lbound(ryzzdoc.member) To Ubound(ryzzdoc.member)
Print |xlsheet.Cells(|+Cstr(i)+|,4).Value="|+Strleft(ryzzdoc.member(k),"/")+|";|
Print |xlsheet.Cells(|+Cstr(i)+|,5).Value="科室员工";|
i=i+1
Next
End If
End If
End If
End If
Set ryzzdoc= view.GetNextDocument(ryzzdoc)
Wend
Print |xlsheet.Columns.AutoFit;|
Print |xls.UserControl = true; //很重要,不能省略,不然会出问题 意思是excel交由用户控制|
Print |xls=null;|
Print |xlBook=null;|
Print |xlsheet=null;|
Print |</script>|
Exit Sub
er:
Msgbox "Error:" + Error$ + " In Ini In Line: " + Cstr(Erl())
End Sub
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240814092323678-2007548550.jpg)