domino导出excell.docx
《domino导出excell.docx》由会员分享,可在线阅读,更多相关《domino导出excell.docx(16页珍藏版)》请在冰点文库上搜索。
domino导出excell
Domino导出excel总结
1.首先加一个导出按钮,并且给该按钮设置一个客户机JavaScript事件。
例如:
@Command([ToolsRunMacro];"exportIdagent")
2.新建一个代理名称为(exportIdagent),设置代理属性:
目标—》无。
设置运行时安
全等级:
允许受限制的操作。
3.在Initialize中添加如下代码:
(以下是自动创建excel)
OnErrorGotoerrhandle
DimssAsNewNotesSession'定义一个session
DimdbAsNotesDatabase'定义数据库
DimcurdocAsNotesDocument'文档上下文
DimpathAsString'domino路径
DimdeptAsString'定义部门
DimstartTimeAsString'定义开始日期
DimoverTimeAsString'定义结束日期
DimdcAsNotesDocumentCollection'定义文档集合
Dimdc2AsNotesDocumentCollection'定义一个子费用单文档集合
DimdocAsNotesDocument'定义一个文档
Dimdoc2AsNotesDocument'定义一个子费用单文档
DimtemAsString'申明日期一个随即数
DimsearchFormulaAsString'申明一个查询的表达式
'以下是根据上下文获取的查询条件
Setcurdoc=ss.DocumentContext'获取上下文
dept=curdoc.F_JDept(0)'部门信息
startTime=curdoc.F_StartTime(0)'开始日期
overTime=curdoc.F_EndTime(0)'结束日期
'查询流程结束并且是普通费报销文档集合
searchFormula=searchFormula&{&(F_DocStatus="完成"|F_DocStatus="通过")}
Ifdept<>""Then
searchFormula=searchFormula&{&F_Dept="}&dept&{"}'判断当部门不为空的时候执行该语句
EndIf
searchFormula=searchFormula&{&(F_CreateTime>=[}&startTime&{])}'[字符串
日期]将字符串转化为日期
searchFormula=searchFormula&{&(F_CreateTime<=[}&overTime&{])}
'设置excel导出信息
DimxlAppAsVariant
DimxlsheetAsVariant
SetxlApp=CreateObject("excel.application")
path=ss.GetEnvironmentString("Directory",True)'获取domino服务端路径
xlApp.statusbar="正在创建工作表,请稍等......"
xlApp.Visible=False'显示excel
xlApp.workbooks.add(path+"\domino\html\lks\koa\cost.xls")'找到对应的费用的模板xlApp.referencestyle=2
Setdb=ss.CurrentDatabase'获取当前数据库
DimrowsAsInteger'申明从第三行开始往excel里面写入数据
rows=3
'========================================获取excel第一个sheet(即普通费用报销信息)=========================================
Setxlsheet=xlapp.workbooks
(1).worksheets
(1)
'以下是获取文档并将其文档写入到excel中
DimcomSerchFormulaAsString'普通费用form帅选
comSerchFormula={(Form="FM_Review")}
comSerchFormula=comSerchFormula&searchFormula
Setdc=db.Search(comSerchFormula,Nothing,0)'获取普通费用报销文档集合
Setdoc=dc.GetFirstDocument()'获取第一个文档
DimaAsInteger
a=0
WhileNot(docIsNothing)
'循环获取大文档中的子文档
Fora=0ToUbound(doc.F_RvPerson)'循环取出大文档中的子文档每个域的数组中的每个值
xlsheet.Cells(rows,1).Value=doc.F_No(0)'单据号
xlsheet.Cells(rows,2).Value=doc.Subject(0)'文档主题
xlsheet.Cells(rows,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)'经办人工号
xlsheet.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=doc.F_RvSection(a)'科目
DimptAsString
pt=doc.F_RvDistribution(a)
Ifpt="0"Then
pt="正常费用"
Else
pt="营销费用"
EndIf
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=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)'付款日期
xlsheet.Cells(rows,24).Value=doc.F_AccountBank(0)'开户行
rows=rows+1
Next
Setdoc=dc.GetNextDocument(doc)'获取下一个文档
Wend
'========================================excel第一个sheet(即差旅费用报销信息)结束=========================================
'========================================获取excel第二个sheet(即差旅费用报销信息)=========================================
DimtravelRowsAsInteger'申明从第三行开始往excel里面写入数据
travelRows=3
Setxlsheet2=xlapp.workbooks
(1).worksheets
(2)
DimtravelSerchFormulaAsString'差旅费用form帅选
travelSerchFormula={(Form="FM_ReviewTravel")}
travelSerchFormula=travelSerchFormula&searchFormula
Setdc=db.Search(travelSerchFormula,Nothing,0)'获取差旅费用报销文档集合
DimiAsInteger
Setdoc=dc.GetFirstDocument()'获取第一个文档
WhileNot(docIsNothing)
'循环获取大文档中的子文档
Fori=0ToUbound(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)'成本中心
DimfpAsString
fp=doc.F_Allocation(0)
Iffp="0"Then
fp="正常费用"
Else
fp="营销费用"
EndIf
xlsheet2.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,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.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_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.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)'出差人
'详细信息结束
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=doc.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
Setdoc=dc.GetNextDocument(doc)'获取下一个文档
Wend
'========================================excel第二个sheet(即差旅费用报销信息)结束=========================================
'========================================获取excel第三个sheet(即福利费用报销信息)=========================================
DimwelfareRowsAsInteger'申明从第三行开始往excel里面写入数据
welfareRows=3
Setxlsheet3=xlapp.workbooks
(1).worksheets(3)'获取第三个sheet(即差旅费用)DimwelfareSerchFormulaAsString'福利费用form帅选
welfareSerchFormula={(Form="FM_ReviewWelfare")}
welfareSerchFormula=welfareSerchFormula&searchFormula
Setdc=db.Search(welfareSerchFormula,Nothing,0)'获取福利费用报销文档集合
DimjAsInteger
Setdoc=dc.GetFirstDocument()'获取第一个文档
WhileNot(docIsNothing)
'循环获取大文档中的子文档
Forj=0ToUbound(doc.F_RvUsage)
xlsheet3.Cells(welfareRows,1).Value=doc.F_No(0)'单据号
xlsheet3.Cells(welfareRows,2).Value=doc.Subject(0)'文档主题
xlsheet3.Cells(welfareRows,3).Value=doc.F_CostCenter(0)'成本中心
DimwelfareAsString
welfare=doc.F_Allocation(0)
Ifwelfare="0"Then
welfare="正常费用"
Else
welfare="营销费用"
EndIf
xlsheet3.Cells(welfareRows,4).Value=welfare'分配
xlsheet3.Cells(welfareRows,5).Value=doc.F_DisCreator(0)'申请人
xlsheet3.Cells(welfareRows,6).Value=doc.F_CreateTime(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_AttachNum(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).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(welfareRows,21).Value=doc.F_PayDate(0)'付款日期
xlsheet3.Cells(welfareRows,22).Value=doc.F_AccountBank(0)'开户行
welfareRows=welfareRows+1
Next
Setdoc=dc.GetNextDocument(doc)'获取下一个文档
Wend
'========================================excel第三个sheet(即福利费用报销信息)结束=========================================
'========================================获取excel第四个sheet(即固定资产报销信息)=========================================
DimfixedRowsAsInteger'申明从第三行开始往excel里面写入数据
fixedRows=3
Setxlsheet4=xlapp.workbooks
(1).worksheets(4)'获取第三个sheet(即固定资产费用)
DimfixedSerchFormulaAsString'固定资产费用form帅选
fixedSerchFormula={(Form="FM_ReviewFixedAssets")}
fixedSerchFormula=fixedSerchFormula&searchFormula
Setdc=db.Search(fixedSerchFormula,Nothing,0)'获取固定资产费用报销文档集合
DimkAsInteger
Setdoc=dc.GetFirstDocument()'获取第一个文档
WhileNot(docIsNothin