1、domino导出excellDomino导出excel总结 1.首先加一个导出按钮,并且给该按钮设置一个客户机JavaScript事件。例如: Command(ToolsRunMacro;exportIdagent) 2.新建一个代理名称为(exportIdagent),设置代理属性:目标无。设置运行时安 全等级:允许受限制的操作。 3.在Initialize中添加如下代码:(以下是自动创建excel) On Error Goto errhandle Dim ss As New NotesSession 定义一个session Dim db As NotesDatabase 定义数据库 Dim
2、 curdoc As NotesDocument 文档上下文 Dim path As String domino路径 Dim dept As String 定义部门 Dim startTime As String 定义开始日期 Dim overTime As String 定义结束日期 Dim dc As NotesDocumentCollection 定义文档集合 Dim dc2 As NotesDocumentCollection 定义一个子费用单文档集合 Dim doc As NotesDocument 定义一个文档 Dim doc2 As NotesDocument 定义一个子费用单文
3、档 Dim tem As String 申明日期一个随即数 Dim searchFormula As String 申明一个查询的表达式 以下是根据上下文获取的查询条件 Set curdoc = ss.DocumentContext 获取上下文 dept = curdoc.F_JDept(0) 部门信息 startTime = curdoc.F_StartTime(0) 开始日期 overTime = curdoc.F_EndTime(0) 结束日期 查询流程结束并且是普通费报销文档集合 searchFormula = searchFormula & & (F_DocStatus=完成|F_D
4、ocStatus=通过) If dept Then searchFormula = searchFormula & & F_Dept= & dept & 判断当部门不为空的时候执行该语句 End If searchFormula = searchFormula & & ( F_CreateTime = & startTime & ) 字符串 日期 将字符串转化为日期 searchFormula = searchFormula & & ( F_CreateTime = & overTime & ) 设置excel导出信息 Dim xlApp As Variant Dim xlsheet As V
5、ariant Set xlApp = CreateObject(excel.application) path = ss.GetEnvironmentString(Directory,True) 获取domino服务端路径 xlApp.statusbar = 正在创建工作表,请稍等. xlApp.Visible = False 显示excel xlApp.workbooks.add(path+dominohtmllkskoacost.xls) 找到对应的费用的模板xlApp.referencestyle = 2 Set db = ss.CurrentDatabase 获取当前数据库 Dim r
6、ows As Integer 申明从第三行开始往excel里面写入数据 rows=3 =获取excel第一个sheet(即普通费用报销信息)= Set xlsheet = xlapp.workbooks(1).worksheets(1) 以下是获取文档并将其文档写入到excel中 Dim comSerchFormula As String 普通费用form帅选 comSerchFormula = (Form = FM_Review) comSerchFormula = comSerchFormula & searchFormula Set dc = db.Search(comSerchForm
7、ula,Nothing,0) 获取普通费用报销文档集合 Set doc = dc.GetFirstDocument() 获取第一个文档 Dim a As Integer a=0 While Not(doc Is Nothing) 循环获取大文档中的子文档 For a = 0 To Ubound(doc.F_RvPerson) 循环取出大文档中的子文档每个域的数组中的每个值 xlsheet.Cells(rows,1).Value = doc.F_No(0) 单据号 xlsheet.Cells(rows,2).Value = doc.Subject(0) 文档主题 xlsheet.Cells(ro
8、ws,3).Value = doc.F_CostCenter(0) 成本中心 xlsheet.Cells(rows,4).Value = doc.F_Sined(0) 签收 xlsheet.Cells(rows,5).Value = doc.F_DisCreator(0) 申请人 xlsheet.Cells(rows,6).Value = doc.F_CreateTime(0) 申请时间 xlsheet.Cells(rows,7).Value = doc.F_Dept(0) 申请部门 xlsheet.Cells(rows,8).Value = doc.F_PerNum(0) 经办人工号 xls
9、heet.Cells(rows,10).Value = doc.F_JDept(0) 经办部门 xlsheet.Cells(rows,11).Value = doc.F_AttachNum(0) 附件张数 以下是详细信息 xlsheet.Cells(rows,9).Value = doc.F_RvPerson(a) 经办人 xlsheet.Cells(rows,12).Value = doc.F_RvMoney(a) 报销金额 xlsheet.Cells(rows,13).Value = doc.F_RvPayReason(a) 用途 xlsheet.Cells(rows,14).Value
10、= doc.F_RvSection(a) 科目 Dim pt As String pt = doc.F_RvDistribution(a) If pt = 0 Then pt=正常费用 Else pt=营销费用 End If xlsheet.Cells(rows,15).Value = pt 分配 xlsheet.Cells(rows,16).Value = doc.F_RvClientName_bf(a) 客户名称 xlsheet.Cells(rows,17).Value = doc.F_RvNotes_bf(a) 备注 详细信息结束 xlsheet.Cells(rows,18).Value
11、 = doc.F_PayType(0) 支付方式 xlsheet.Cells(rows,19).Value = doc.F_PayAbstract(0) 支付摘要 xlsheet.Cells(rows,20).Value = doc.F_PayMoney(0) 支付金额 xlsheet.Cells(rows,21).Value = doc.F_InMoneyUnit(0) 收款人名称 xlsheet.Cells(rows,22).Value = doc.F_InAccount(0) 收款账号 xlsheet.Cells(rows,23).Value = doc.F_PayDate(0) 付款日
12、期 xlsheet.Cells(rows,24).Value = doc.F_AccountBank(0) 开户行 rows =rows + 1 Next Set doc = dc.GetNextDocument(doc) 获取下一个文档 Wend =excel第一个sheet(即差旅费用报销信息)结束= =获取excel第二个sheet(即差旅费用报销信息)= Dim travelRows As Integer 申明从第三行开始往excel里面写入数据 travelRows=3 Set xlsheet2 = xlapp.workbooks(1).worksheets(2) Dim trave
13、lSerchFormula As String 差旅费用form帅选 travelSerchFormula = (Form = FM_ReviewTravel) travelSerchFormula = travelSerchFormula & searchFormula Set dc = db.Search(travelSerchFormula,Nothing,0) 获取差旅费用报销文档集合 Dim i As Integer Set doc = dc.GetFirstDocument() 获取第一个文档 While Not(doc Is Nothing) 循环获取大文档中的子文档 For i
14、 = 0 To Ubound(doc.F_RvLevalAddress) xlsheet2.Cells(travelRows,1).Value = doc.F_No(0) 单据号 xlsheet2.Cells(travelRows,2).Value = doc.Subject(0) 文档主题 xlsheet2.Cells(travelRows,3).Value = doc.F_CostCenter(0) 成本中心 Dim fp As String fp = doc.F_Allocation(0) If fp = 0 Then fp=正常费用 Else fp=营销费用 End If xlshee
15、t2.Cells(travelRows,4).Value = fp 分配 xlsheet2.Cells(travelRows,5).Value = doc.F_DisCreator(0) 申请人 xlsheet2.Cells(travelRows,6).Value = doc.F_CreateTime(0) 申请时间 xlsheet2.Cells(travelRows,7).Value = doc.F_Dept(0) 申请部门 xlsheet2.Cells(travelRows,8).Value = doc.F_PerNum(0) 经办人工号 xlsheet2.Cells(travelRows
16、,9).Value = doc.F_JDept(0) 经办部门 xlsheet2.Cells(travelRows,10).Value = doc.F_ClientName(0) 客户名称 xlsheet2.Cells(travelRows,11).Value = doc.F_AttachNum(0) 附件张数 以下是详细信息 xlsheet2.Cells(travelRows,12).Value = doc.F_RvStartTime(i) 开始日期 xlsheet2.Cells(travelRows,13).Value = doc.F_RvEndTime(i) 结束日期 xlsheet2.
17、Cells(travelRows,14).Value = doc.F_RvLevalAddress(i) 出发地 xlsheet2.Cells(travelRows,15).Value = doc.F_RvDestination(i) 目的地 xlsheet2.Cells(travelRows,16).Value = doc.F_RvTravelReason(i) 出差事由 xlsheet2.Cells(travelRows,17).Value = doc.F_RvSection(i) 科目 xlsheet2.Cells(travelRows,18).Value = getArr(doc.F_
18、RvTrafficTool,i) doc.F_RvTrafficTool(i) 交通工具 xlsheet2.Cells(travelRows,19).Value = getArr(doc.F_RvTrafficFees,i) doc.F_RvTrafficFees(i) 交通费用 xlsheet2.Cells(travelRows,20).Value = getArr(doc.F_RvStayDays,i) doc.F_RvStayDays(i) 住宿天数 xlsheet2.Cells(travelRows,21).Value = getArr(doc.F_RvStayFees,i) doc.
19、F_RvStayFees(i) 住宿费用 xlsheet2.Cells(travelRows,22).Value = getArr(doc.F_RvOtherUse,i) doc.F_RvOtherUse(i) 其他费用用途 xlsheet2.Cells(travelRows,23).Value = getArr(doc.F_RvOtherFees,i) doc.F_RvOtherFees(i) 其他费用金额 xlsheet2.Cells(travelRows,24).Value = getArr(doc.F_RvTravelPerson,i) doc.F_RvTravelPerson(i)
20、出差人 详细信息结束 xlsheet2.Cells(travelRows,25).Value = doc.F_PayType(0) 支付方式 xlsheet2.Cells(travelRows,26).Value = doc.F_PayAbstract(0) 支付摘要 xlsheet2.Cells(travelRows,27).Value = doc.F_PayMoney(0) 支付金额 xlsheet2.Cells(travelRows,28).Value = doc.F_InMoneyUnit(0) 收款人名称 xlsheet2.Cells(travelRows,29).Value = d
21、oc.F_InAccount(0) 收款账号 xlsheet2.Cells(travelRows,30).Value = doc.F_PayDate(0) 付款日期 xlsheet2.Cells(travelRows,31).Value = doc.F_AccountBank(0) 开户行 travelRows =travelRows + 1 Next Set doc = dc.GetNextDocument(doc) 获取下一个文档 Wend =excel第二个sheet(即差旅费用报销信息)结束= =获取excel第三个sheet(即福利费用报销信息)= Dim welfareRows A
22、s Integer 申明从第三行开始往excel里面写入数据 welfareRows=3 Set xlsheet3 = xlapp.workbooks(1).worksheets(3) 获取第三个sheet(即差旅费用) Dim welfareSerchFormula As String 福利费用form帅选 welfareSerchFormula = (Form = FM_ReviewWelfare) welfareSerchFormula = welfareSerchFormula & searchFormula Set dc = db.Search(welfareSerchFormula
23、,Nothing,0) 获取福利费用报销文档集合 Dim j As Integer Set doc = dc.GetFirstDocument() 获取第一个文档 While Not(doc Is Nothing) 循环获取大文档中的子文档 For j = 0 To Ubound(doc.F_RvUsage) xlsheet3.Cells(welfareRows,1).Value = doc.F_No(0) 单据号 xlsheet3.Cells(welfareRows,2).Value = doc.Subject(0) 文档主题 xlsheet3.Cells(welfareRows,3).Va
24、lue = doc.F_CostCenter(0) 成本中心 Dim welfare As String welfare = doc.F_Allocation(0) If welfare = 0 Then welfare=正常费用 Else welfare=营销费用 End If xlsheet3.Cells(welfareRows,4).Value = welfare 分配 xlsheet3.Cells(welfareRows,5).Value = doc.F_DisCreator(0) 申请人 xlsheet3.Cells(welfareRows,6).Value = doc.F_Crea
25、teTime(0) 申请时间 xlsheet3.Cells(welfareRows,7).Value = doc.F_Dept(0) 申请部门 xlsheet3.Cells(welfareRows,8).Value = doc.F_PerNum(0) 经办人工号 xlsheet3.Cells(welfareRows,9).Value = doc.F_RvPerson(j) 经办人 xlsheet3.Cells(welfareRows,10).Value = doc.F_JDept(0) 经办部门 xlsheet3.Cells(welfareRows,11).Value = doc.F_Atta
26、chNum(0) 附件张数 以下是详细信息 xlsheet3.Cells(welfareRows,12).Value = doc.F_RvUsage(j) 用途 xlsheet3.Cells(welfareRows,13).Value = doc.F_RvSection(j) 科目 xlsheet3.Cells(welfareRows,14).Value = doc.F_RvMoney(j) 报销金额 xlsheet3.Cells(welfareRows,15).Value = doc.F_RvNotes(j) 备注 详细信息结束 xlsheet3.Cells(welfareRows,16).
27、Value = doc.F_PayType(0) 支付方式 xlsheet3.Cells(welfareRows,17).Value = doc.F_PayAbstract(0) 支付摘要 xlsheet3.Cells(welfareRows,18).Value = doc.F_PayMoney(0) 支付金额 xlsheet3.Cells(welfareRows,19).Value = doc.F_InMoneyUnit(0) 收款人名称 xlsheet3.Cells(welfareRows,20).Value = doc.F_InAccount(0) 收款账号 xlsheet3.Cells
28、(welfareRows,21).Value = doc.F_PayDate(0) 付款日期 xlsheet3.Cells(welfareRows,22).Value = doc.F_AccountBank(0) 开户行 welfareRows =welfareRows + 1 Next Set doc = dc.GetNextDocument(doc) 获取下一个文档 Wend =excel第三个sheet(即福利费用报销信息)结束= =获取excel第四个sheet(即固定资产报销信息)= Dim fixedRows As Integer 申明从第三行开始往excel里面写入数据 fixe
29、dRows=3 Set xlsheet4 = xlapp.workbooks(1).worksheets(4) 获取第三个sheet(即固定资产费用) Dim fixedSerchFormula As String 固定资产费用form帅选 fixedSerchFormula = (Form = FM_ReviewFixedAssets) fixedSerchFormula = fixedSerchFormula & searchFormula Set dc = db.Search(fixedSerchFormula,Nothing,0) 获取固定资产费用报销文档集合 Dim k As Integer Set doc = dc.GetFirstDocument() 获取第一个文档 While Not(doc Is Nothin
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2