Lotus 技术点之导出

 
a)          导出到excel中
Sub Click(Source As Button)
Dim s As New notessession
Dim db As notesdatabase
Dim view As notesview
Dim dc As notesdocumentcollection
Dim doc As notesdocument
Dim vcols As Variant
Dim uvcols As Integer
 
Set db = s.currentdatabase
Set dc = db.unprocesseddocuments
Set view = db.getview("当前视图的名称 ")
uvcols=Ubound(view.columns)
 
Dim xlapp As Variant
Dim xlsheet As Variant
'创建一个Excel对象
Set xlapp=createobject("Excel.application")
xlapp.statusbar = "正在创建工作表,请稍等......"
xlapp.visible = True
'添加工作薄
xlapp.workbooks.add
xlapp.referencestyle = 2
Set xlsheet = xlapp.workbooks(1).worksheets(1)
'为工作表命名
xlsheet.name = "notes export"
Dim rows As Integer
rows = 1
Dim cols As Integer
cols = 1
Dim maxcols As Integer
For x=0 To Ubound(view.columns)
 xlapp.statusbar = "正在创建单元格,请稍等...... "
 If view.columns(x).IsHidden = False Then
   If view.columns(x).title<>"" Then
    xlsheet.cells(rows,cols).value = view.columns(x).title
    cols = cols + 1
   End If
End If
Next
maxcols=cols-1
 
Set doc=dc.getfirstdocument
Dim fieldname As String
Dim fitem As notesitem
rows=2
cols=1
 
Do While Not(doc Is Nothing)
 For x=0 To Ubound(view.columns)
   xlapp.statusbar="正在从Notes中引入数据,请稍等......"
   If view.columns(x).IsHidden=False Then
    If view.columns(x).title<>"" Then
     fieldname = view.columns(x).itemname
     Set fitem = doc.getfirstitem(fieldname)
     xlsheet.cells(rows, cols).value = fitem.text
     cols = cols +1
    End If
   End If
 Next
 rows = rows+1
 cols = 1
 Set doc= dc.getnextdocument(doc)
Loop
 
%REM
xlApp.Row s("1:1").select
xlApp.Selection.Font.Bold=True
xlApp.Range(xls heet.cells(1,1),xlsheet.Cells(rows,maxcols)).Select
xlApp.Selection.Fon t.Name="Arial"
xlApp.Selection.Font.Size=9
xlApp.Selcetion.Col umns.Autofit
%END REM
 
With xlapp.worksheets(1)
 .pagesetup.orientation = 2
 .pagesetup.centerheader = "report _ confidential"
 .pagesetup.rightfooter = "page &P" & Chr$(13) & "Date:&D"
 .pagesetup.CenterFooter = ""
End With
 
xlapp.referencestyle = 1
xlapp.range("A1").Select
xlapp.statusbar = "数据导入完成。"
End Sub
 
b)         以表格形式导出
Sub Initialize
%REM
功能:导出内部数据到Excel中去
作者:xxx
最后修改时间:
%END REM
       On Error Goto unknowErr
       Dim session As New NotesSession
       Dim db As NotesDatabase
       Dim view As NotesView
       Dim tempdoc As NotesDocument
       Dim strTemp As String
      
       Dim strPath As String
       If session.CurrentDatabase.FilePath=session.CurrentDatabase.FileName Then
              strPath=""
       Else
              strPath=Strleftback(session.CurrentDatabase.FilePath,session.CurrentDatabase.FileName)
       End If
       Set db=New NotesDatabase("",strPath & "db_StaffInformation.nsf")
       Set view=db.GetView("hvpersonInfo")
      
       Print {Content-disposition:attachment; filename=data.xls}
       Print {<table border="1">}
       Print {<tr>}
       Print {<td>工号</td>}
       Print {<td>姓名</td>}
       Print {<td>性别</td>}
       Print {<td>单位名称</td>}
       Print {<td>职位</td>}
       Print {<td>办公地点</td>}
       Print {<td>办公电话</td>}
       Print {<td>移动电话</td>}
       Print {<td>传真</td>}
       Print {<td>IP地址</td>}
       Print {<td>邮政编码</td>}
       Print {<td>电子邮件</td>}
       Print {<td>联系地址</td>}
       Print {</tr>}
       '填写数据
       Set tempDoc=view.GetFirstDocument
       While Not tempDoc Is Nothing
              Print {<tr>}
              '工号
              Print {<td >} & Cstr(tempDoc.EmployeeID(0)) & {</td>}
              '姓名
              Dim neibuName As NotesName
              Set neibuName=New NotesName(tempDoc.myname(0))
              Print {<td >} & neibuName.Common & {</td>}
              Print {<td >} & tempDoc.Sex(0) & {</td>}
              '工作单文
              If neibuName.OrgUnit1<>"" Then
                     strTemp=neibuName.OrgUnit1
              End If
              If neibuName.OrgUnit2<>"" Then
                     strTemp=strTemp & "/" & neibuName.OrgUnit2
              End If
              If neibuName.OrgUnit3<>"" Then
                     strTemp=strTemp & "/" & neibuName.OrgUnit3
              End If
              If neibuName.OrgUnit4<>"" Then
                     strTemp=strTemp & "/" & neibuName.OrgUnit4
              End If
              Print {<td >} & strTemp & {</td>}
              '职务
              If tempDoc.JobTitle(0)="1" Then
                     strTemp="员工"
              End If
              If tempDoc.JobTitle(0)="2" Then
                     strTemp="业务主管"
              End If
              If tempDoc.JobTitle(0)="3" Then
                     strTemp="副经理"
              End If
              If tempDoc.JobTitle(0)="4" Then
                     strTemp="部门经理"
              End If
              If tempDoc.JobTitle(0)="5" Then
                     strTemp="分管领导"
              End If
              If tempDoc.JobTitle(0)="6" Then
                     strTemp="总经理"
              End If
              If tempDoc.JobTitle(0)="7" Then
                     strTemp="董事长"
              End If
              Print {<td >} & strTemp & {</td>}
              Print {<td >} & tempDoc.Location(0) & {</td>}
              Print {<td >} & tempDoc.OfficePhoneNumber(0) & {</td>}
              Print {<td >} & tempDoc.CellPhoneNumber(0) & {</td>}
              Print {<td >} & tempDoc.OfficeFAXPhoneNumber(0) & {</td>}
              Print {<td >} & tempDoc.IP(0) & {</td>}
              Print {<td >} & tempDoc.OfficeZIP(0) & {</td>}
              Print {<td >} & tempDoc.InternetAddress(0) & {</td>}
              Print {<td >} & tempDoc.OfficeStreetAddress(0) & {</td>}
              Print {</tr>}
              Set tempDoc=view.GetNextDocument(tempDoc)
       Wend
       Print {</table>}
       Exit Sub
unknowErr:
       Messagebox "错误行:" & Erl & "错误信息:" & Error
End Sub
 
 
c) BS环境下导出
Option Public
Use  "sysFunctionScript"
Sub Initialize
 Dim file_view As NotesView
 Dim dept_view As NotesView
 Dim dept_doc As NotesDocument
 Dim role_view As NotesView
 Dim role_doc As NotesDocument
 Dim user_view As NotesView
 Dim user_doc As NotesDocument
 Dim i As Integer
 Dim var_id As Variant
 Dim str_id As String
 Dim str_path As String
  str_path=session.GetEnvironmentString("NotesProgram",true)

 On Error Goto ef
 
 REM 删除,临时生成的组织结构附件
 Set file_view=cur_db.GetView("outFile_view")
 If file_view.AllEntries.Count>0 Then
  Call file_view.AllEntries.RemoveAll(True)
 End If 
 
 i=1
 REM 导出部门
 Set dept_view=cur_db.GetView("exportDept_View")
 If dept_view.AllEntries.Count>0 Then ''存在部门
  DbPath$=str_path+"\"+Format(Cstr(Today()),"YYYY-MM-DD")+"组织结构.xls"
  fileName$=Format(Cstr(Today()),"YYYY-MM-DD")+"组织结构.xls"
  Set exapp=CreateObject("Excel.Application")  
  exapp.visible=False
  Set exwk=exapp.workbooks.add
  Set exsh=exwk.worksheets("sheet1") 
  exsh.Range("A1").Value = "部门ID"  
  exsh.Range("B1").Value = "编号"
  exsh.Range("C1").Value = "部门代码"
  exsh.Range("D1").Value = "部门名称"
  exsh.Range("E1").Value = "直接上级部门全称"
  Set dept_doc=dept_view.GetFirstDocument()
  While Not(dept_doc Is Nothing)
   i=i+1
   exsh.Range("A"+Cstr(i)).Value =  "'"+Cstr(dept_doc.DID(0))
   exsh.Range("B"+Cstr(i)).Value = Cstr(dept_doc.DOrder(0))
   exsh.Range("C"+Cstr(i)).Value = Cstr(dept_doc.unitCode(0))
   exsh.Range("D"+Cstr(i)).Value =Cstr(dept_doc.DName(0))
  ' exsh.range("D"+Cstr(i)).WrapText=True   '单元格自动
   exsh.Range("E"+Cstr(i)).Value =Cstr(dept_doc.DFName(0))
   Set dept_doc=dept_view.GetNextDocument(dept_doc)
  Wend
      REM 导出职务
  Set role_view=cur_db.GetView("role_View")
  If role_view.AllEntries.Count>0 Then ''存在职务
   Set exsh=exwk.worksheets("sheet2") 
   exsh.Range("A1").Value = "职位ID"  
   exsh.Range("B1").Value = "编号"
   exsh.Range("C1").Value = "职务代码"
   exsh.Range("D1").Value = "职务名称"
   exsh.Range("E1").Value = "所在部门"
   
   Set role_doc=role_view.GetFirstDocument()
   i=1
   While Not(role_doc Is Nothing)
    i=i+1
    exsh.Range("A"+Cstr(i)).Value =  "'"+Cstr(role_doc.RID(0))
    exsh.Range("B"+Cstr(i)).Value = Cstr(role_doc.ROrder(0))
    exsh.Range("C"+Cstr(i)).Value = Cstr(role_doc.roleCode(0))
    exsh.Range("D"+Cstr(i)).Value = Cstr(role_doc.RName(0))
    exsh.Range("E"+Cstr(i)).Value =Cstr(role_doc.RDName(0))
    Set role_doc=role_view.GetNextDocument(role_doc)
   Wend
   
   REM 导出人员   
   Set user_view=cur_db.GetView("user_View")
   If user_view.AllEntries.Count>0 Then ''存在人员
    Set exsh=exwk.worksheets("sheet3") 
    exsh.Range("A1").Value = "编号"
    exsh.Range("B1").Value = "工号"
    exsh.Range("C1").Value = "姓名"
    exsh.Range("D1").Value = "职位"
    exsh.Range("E1").Value = "默认密码(不输入默认:123456)"
    exsh.Range("F1").Value = "性别"
    exsh.Range("G1").Value = "邮件名(空值默认邮件为姓名)"
    exsh.Range("H1").Value = "别名"
    exsh.Range("I1").Value = "interNet邮箱"
    exsh.Range("J1").Value = "第一级主管"
    exsh.Range("K1").Value = "第二级主管"
    exsh.Range("L1").Value = "第三级主管"
    exsh.Range("M1").Value = "第四级主管"
    Set user_doc=user_view.GetFirstDocument()
    i=1
    While Not(user_doc Is Nothing)     
     i=i+1
     exsh.Range("A"+Cstr(i)).Value = Cstr(user_doc.UOrder(0))
     exsh.Range("B"+Cstr(i)).Value =  "'"+ Cstr(user_doc.UNumber(0))
     exsh.Range("C"+Cstr(i)).Value = Cstr(user_doc.UName(0))
     exsh.Range("D"+Cstr(i)).Value =Cstr(user_doc.URName(0))
     exsh.Range("E"+Cstr(i)).Value =Cstr("123456")
     exsh.Range("F"+Cstr(i)).Value =Cstr(user_doc.USex(0))
     exsh.Range("G"+Cstr(i)).Value =Cstr(user_doc.UMail(0))
     exsh.Range("H"+Cstr(i)).Value =  "'"+Cstr(user_doc.UBName(0))
     exsh.Range("I"+Cstr(i)).Value =Cstr(user_doc.Uimail(0))
     
     str_id=""
     If user_doc.UManagerUnid1(0)<>"" Then
      var_id=Split(user_doc.UManagerUnid1(0),",")
      For a=0 To UBound(var_id)
       If strleft(var_id(a),1)="D" Then
        str_id=str_id+","+funSystemGetDeptNameByDeptID(var_id(a))
       Else
        If StrLeft(var_id(a),1)="R" Then
         str_id=str_id+","+funSystemGetRoleNameByRoleID(var_id(a))
        Else
         str_id=str_id+","+StrRight(var_id(a),"P")
        End If
       End If
      Next
     End If
     exsh.Range("J"+Cstr(i)).Value =StrRight(str_id,",")
     str_id=""
     If user_doc.UManagerUnid2(0)<>"" Then
      var_id=Split(user_doc.UManagerUnid2(0),",")
      For a=0 To UBound(var_id)
       If StrLeft(var_id(a),1)="D" Then
        str_id=str_id+","+funSystemGetDeptNameByDeptID(var_id(a))
       Else
        If StrLeft(var_id(a),1)="R" Then
         str_id=str_id+","+funSystemGetRoleNameByRoleID(var_id(a))
        Else
         str_id=str_id+","+StrRight(var_id(a),"P")
        End If
       End If
      Next
     End If     
     exsh.Range("K"+Cstr(i)).Value =StrRight(str_id,",")
     str_id=""     
     If user_doc.UManagerUnid3(0)<>"" Then
       var_id=Split(user_doc.UManagerUnid3(0),",")
      For a=0 To UBound(var_id)
       If StrLeft(var_id(a),1)="D" Then
        str_id=str_id+","+funSystemGetDeptNameByDeptID(var_id(a))
       Else
        If StrLeft(var_id(a),1)="R" Then
         str_id=str_id+","+funSystemGetRoleNameByRoleID(var_id(a))
        Else
         str_id=str_id+","+StrRight(var_id(a),"P")
        End If
       End If
      Next
     End If 
     exsh.Range("L"+Cstr(i)).Value =StrRight(str_id,",")
     str_id=""
     If user_doc.UManagerUnid4(0)<>"" Then
      var_id=Split(user_doc.UManagerUnid4(0),",")
      For a=0 To UBound(var_id)
      ' print  var_id(a)+"--"+StrLeft(var_id(a),1)
       
       If StrLeft(var_id(a),1)="D" Then
        str_id=str_id+","+funSystemGetDeptNameByDeptID(var_id(a))
       Else
        If StrLeft(var_id(a),1)="R" Then
         str_id=str_id+","+funSystemGetRoleNameByRoleID(var_id(a))
        Else
         str_id=str_id+","+StrRight(var_id(a),"P")
        End If
       End If
      Next
     End If 
     exsh.Range("M"+Cstr(i)).Value =StrRight(str_id,",")
     
     Set user_doc=user_view.GetNextDocument(user_doc)
    Wend
   End If
  End If
  exwk.SaveAs(DbPath$)
  Dim ftpItem As NotesRichTextItem          '放到附件里
  Dim ftpOBJ As NotesEmbeddedObject
  Dim ftpDoc As NotesDocument
  Dim item As NotesItem
  Set ftpDoc=cur_db.CreateDocument
  
  keyWord$=Cstr(Now())
  ftpDoc.form="outFile_Form" ''表单名
  ftpDoc.keyWord=keyWord$ ''打开关键字
  ftpDoc.writer="*"
  Set item=ftpDoc.GetFirstItem("writer")
  item.IsAuthors=True
  Set ftpItem=New NotesRichTextItem(ftpDoc,"body")
  Set ftpOBJ=ftpItem.EmbedObject(EMBED_ATTACHMENT,"",DbPath$)
  Call ftpDoc.Save(True,False)
  exapp.quit 
  Set exapp=Nothing
  Kill DbPath$   
  filePath$="/"+Strleft(cur_db.FilePath,"\")+"/sysZZJG.nsf/outFile_view/"+ftpDoc.UniversalID+"/$FILE/"+fileName$
  
  Set file_view=Nothing
  Set dept_view=Nothing
  Set dept_doc=Nothing
  Set role_view=Nothing
  Set role_doc=Nothing
  Set user_view=Nothing
  Set user_doc=Nothing
  
  Print |<script language="javascript">|
  Print |window.location="|+filePath$+|"|
  Print |</script>|  
 End If
 
 Exit Sub
ef:
 Msgbox "【导出组织机构)|(exportUnit_Agent】"& Error$ & " at line " & Cstr(Erl)
 Exit Sub
End Sub
 
 
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
订单实时提醒系统[提供ASP源码]系统图解: http://www.public.gov.cn/PublicRtx.jpg http://www.public.gov.cn/PublicRtx1.jpg按装说明: 下载地址:http://www.public.gov.cn/Down.asp 申请地址:http://www.public.gov.cn/reg1.asp http://rtx.tencent.com/cgi-bin/rtx_dl RTX服务端软件 http://218.18.95.202/download/RTXCLT_330_STD_Build_1997.EXE RTX客户端软件 http://www.public.gov.cn/SetupEx.Exe 公众商务通软件 http://www.public.gov.cn/RTX_mail.pps 幻灯演示文件系统说明:1.你网站订单即时提醒2.送货调度功能3.组织结构功能——通过软件快速方便了解企业及同事  通过软件客户端浏览企业组织结构  企业电子通讯录,在软件上直接查看对方电话分机、手机号码等信息4.管理功能——确保企业信息的安全与网络资源的合理利用  允许/禁止某项功能  强制对接收到的文件进行病毒扫描  信息存档  代理和端口设置,指定信息交互通道  *设定用户交流对象  *支持LDAP,例如可以直接导入IBM Lotus、微软Exchange的用户信息,共享用户目录信息5.即时信息交互——全面提升沟通方式与沟通速度  查看联系人状态信息  即时消息发送与接收  多人会话  文件传送  截图功能  直接贴图功能  录制、发送语音片断  语音/视频交流  自定义讨论组  查找企业内外联系人  动画表情符、表情符定制  广播群发消息  查找联系人  在线人员列表统计  投票功能6.企业短信中心——实现企业办公与手机的紧密结合  手机短信发送与接收(中国移动、中国联通手机)  短信群发  可发送短信数目控制、发送情况统计  短信查资料,例如发送短信到企业服务号码查同事联系方式(前提是该手机有权限)  自定义手机联系人分组  手机联系人资料导入导出7.视频语音网络会议——大幅度节省沟通成本  会议预定与定时提醒  文字、语音、视频交流  完整的会议记录与回放8.信息资料管理——实现信息保存与方便日后查询与回顾  客户端数据压缩保存  历史信息记录查询  通讯录  历史信息导入导出9.QQ互连功能——实现企业与7700万QQ活跃用户在可管理前提下的互通  与普通QQ用户的互通  对是否可与QQ互通的权限管理  对与QQ用户互通的信息存档监控10.与office的集成——与主流办公软件的结合  OfficeXP以上版本中出现软件用户名和手机号码的地方可以进行即时通信,如下图所示。11.与邮件的整合——集成现代企业办公的重要沟通方式  *邮件到达提醒  *软件离线消息转邮件  软件客户端进行邮件直接发送操作12.日常办公辅助功能  备忘录功能  待办事项功能,可将交流信息直接存储为待办事项13.应用程序共享——实现远程协作  共享本机的应用程序,可实现远程协作14.企业定制功能——使软件拥有企业特色  定制企业名称  定制企业标志  定制企业信息之窗15.与电话网络集成——实现电脑网络与电话的结合  支持IP电话  *支持SIP电话16.软件 WEB客户端功能——办公出差随时随地通信息  通过浏览器登陆企业软件服务器。提供简体中文、繁体中文(含转换机制,与简体版本交流不乱码)、英文等多语言版本,适合外企或者有跨国业务的企业交流使用。以后Web客户端还可以非常容易地内嵌,并统一到客户基于Web的信息平台上。17.*企业分支互联功能——企业不同分支机构之间交流  对有特殊需求的企业,例如各个分支机构需要自行管理用户,但分支机构之间要全面互通,可以通过软件分支互联功能实现。18.软件企业互联功能——企业之间的沟通更畅通  通过软件与其他软件企业用户互通安装步骤:1.下载好软件2.申请会员(FREE)[http://www.public.gov.cn/reg1.asp]3.安装RTX服务端和公众商务通软件4.进入网站会员后台,在“RTX用户内”获得RTX,如果没有请联系我们(FREE)也可以自己用服务端申请5.登陆系统:RTX服务端用RTX号和密码;公众商务通软件用网站会员用户名密码6.使用RTX服务端开设分机号7.给其它员工电脑安装RTX客户端软件,用开好的分机号和密码登陆8.再到我们网站发布产品,或到网站“RTX权限”内获得代码加到你的网站上9.将你的产品信息绑定指定接收的分机号上或以多号,可以群发10.如果你要离线短信通知,可以在RTX客户端软件上绑定你的手机号,这们就安装完成了 详情请看:http://www.public.gov.cn/rtxabout.aspURL接口:http://www.public.gov.cn/sendsms.asp?user=dailei&pass=548899&rtx=RTX号码(ALL为群发,多号可以逗号分开如:1111,1112)&title=信息标题&sms=信息内容ASP接口:<%user="Admin" ‘用户名pass="Admin" ‘密码rtx="1001,1002" ‘RTX号码(小写的all为群发,多号可以逗号分开如:1111,1112title="订购产品通知" ‘标题sms="信息内容*/信息内容2" ‘信息内容 */ 表示回车符Function GetURL(url) Set Retrieval = CreateObject("Microsoft.XMLHTTP") With Retrieval .Open "GET", url, False, "", "" .Send GetURL = .ResponseText End With Set Retrieval = Nothing End Function url="http://www.public.gov.cn/sendsms.asp?user="&user&"&pass="&pass&"&rtx="&rtx&"&title="&title&"&sms="&sms&""T=GetURL(url)if T="0" thenResponse.Write "信息发送成功"elseif T="1" thenResponse.Write "信息发送出错"end if%>

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值