HTML部分
—————————————————————————————————————————————————————————————————————————————————————
1 <table style="WIDTH: 99%; BORDER-COLLAPSE: collapse" class="linkeytable"> 2 <tbody> 3 <tr> 4 <td width="15%" align="right">受理时间:</td> 5 <td width="85%">从 6 <input name="dStart" />到 7 <input name="dEnd" /></td> 8 </tr> 9 <tr> 10 <td width="15%" align="right"> 11 <input class="lsbtn" onclick="ExportExcel()" name="toExcel" value="导出Excel" type="button" /></td> 12 <td width="85%"> 13 <table style="WIDTH: 40%; BORDER-COLLAPSE: collapse"> 14 <tbody> 15 <tr> 16 <td width="33.33%"> 17 <input class="lschk" name="sMutiCol" value="FeedBackUnion" checked="checked" type="checkbox" />用户单位</td> 18 <td width="33.33%"> 19 <input class="lschk" name="sMutiCol" value="callback" checked="checked" type="checkbox" />是否回电</td> 20 <td width="33.33%"> 21 <input class="lschk" name="sMutiCol" value="zdds" checked="checked" type="checkbox" />中断局点数</td> 22 </tr> 23 <tr> 24 <td width="33.33%"> 25 <input class="lschk" name="sMutiCol" value="overseas" checked="checked" type="checkbox" />地域</td> 26 <td width="33.33%"> 27 <input class="lschk" name="sMutiCol" value="customerclass" checked="checked" type="checkbox" />客户级别</td> 28 <td width="33.33%"> 29 <input class="lschk" name="sMutiCol" value="ProblemDes" checked="checked" type="checkbox" />问题描述</td> 30 </tr> 31 <tr> 32 <td width="33.33%"> 33 <input class="lschk" name="sMutiCol" value="ProblemType2" checked="checked" type="checkbox" />问题类型</td> 34 <td width="33.33%"> 35 <input class="lschk" name="sMutiCol" value="DealTimeNeeded" checked="checked" type="checkbox" />希望解决时间</td> 36 <td width="33.33%"> 37 <input class="lschk" name="sMutiCol" value="ID3" checked="checked" type="checkbox" />指定问题接口人</td> 38 </tr> 39 <tr> 40 <td width="33.33%"> 41 <input class="lschk" name="sMutiCol" value="FeedBackMan" checked="checked" type="checkbox" />客户姓名</td> 42 <td width="33.33%"> 43 <input class="lschk" name="sMutiCol" value="province" checked="checked" type="checkbox" />省份</td> 44 <td width="33.33%"> 45 <input class="lschk" name="sMutiCol" value="SerialNo" checked="checked" type="checkbox" />编号</td> 46 </tr> 47 <tr> 48 <td width="33.33%"> 49 <input class="lschk" name="sMutiCol" value="ConnectPhone" checked="checked" type="checkbox" />联系电话 </td> 50 <td width="33.33%"> 51 <input class="lschk" name="sMutiCol" value="fldzdsj" checked="checked" type="checkbox" />工程中断发生时间</td> 52 <td width="33.33%"> 53 <input class="lschk" name="sMutiCol" value="FeedBacktime" checked="checked" type="checkbox" />受理时间</td> 54 </tr> 55 </tbody> 56 </table></td> 57 </tr> 58 </tbody> 59 </table> 60 <div style="DISPLAY: none" id="rs"> </div>
——————————————————————————————————————————————————————————————————————————————————————
JS部分
——————————————————————————————————————————————————————————————————————————————————————
1 function ExportExcel(){ 2 var doc =document; 3 var objs=doc.getElementsByName("sMutiCol"); 4 var arr=new Array(); 5 var arr2=new Array(); 6 var j=0; 7 for(i=0;i<objs.length;i++){ 8 if(objs[i].checked==true){ 9 arr[j]=objs[i].value; 10 arr2[j]=objs[i].nextSibling.nodeValue; 11 j=j+1; 12 } 13 } 14 var str=arr.join("#"); 15 var str2=arr2.join("#"); 16 var dStart=GetObj("dStart").value; 17 var dEnd=GetObj("dEnd").value; 18 if(dStart=="" || dEnd==""){ alert("开始及结束日期不得为空!");} 19 else{ 20 var url="/"+folder+"/app.nsf/WF_RunRule?openagent&RuleNum=RUh3cts001_005"; 21 $(function(){ 22 $.post(url,{dstart:dStart,dend:dEnd,str:str,str2:str2},function(data){ 23 $("#rs").html(data); 24 var curT=doc.getElementById("tab"); 25 var oXL=new ActiveXObject("Excel.Application"); 26 var oWB=oXL.Workbooks.add(); 27 var oSheet=oWB.ActiveSheet; 28 var lenRow=curT.rows.length; 29 for (i = 0; i < lenRow; i++){ 30 var lenCol = curT.rows(i).cells.length; 31 for (j = 0; j < lenCol; j++){ 32 oSheet.Cells(i + 1, j + 1).value = "'"+curT.rows(i).cells(j).innerText; 33 } 34 } 35 oXL.Visible = true; 36 }); 37 }); 38 } 39 }
—————————————————————————————————————————————————————————————————————————
LS部分
—————————————————————————————————————————————————————————————————————————Sub Initialize
On Error Goto errormsg
msgbox "h3cts001:Export Begin"
dim se as new notessession
dim curdoc as notesdocument
dim sql as string
set curdoc=se.documentContext
dim strFormular as string
dim vData as variant
dim vQry as variant
dim items as variant,items2 as variant
dim i as integer,j as integer
dim vdt as string,vde as string,vStr as string,vStr2 as string
strFormular="@URLDecode('Domino';Request_Content)"
vData=Evaluate(strFormular,curdoc)
vQry=split(vData(0),"&")
vdt=strright(vQry(0),"=")
vde=strright(vQry(1),"=")
vStr=strright(vQry(2),"=")
vStr2=strright(vQry(3),"=")
items=split(vStr,"#")
items2=split(vStr2,"#")
j=ubound(items)
dim fldlst as new lcfieldlist
dim tmpdoc as notesdocument
dim v as variant
dim e as notesitem
dim htmlstr as string
sql=|select * from bpm_maindata where WF_DocStatus<>'DraftDoc' and WF_AppId='h3cts001' and WF_DocCreated between '|+vdt+|' and '|+vde+|'|
call WF_Con.execute(sql,fldlst)
Print |Content-Type:application/vnd.ms-excel;charset=GBK|
Print |<meta http-equiv="Content-Type" content="text/html; charset=GBK">|
htmlstr = htmlstr & "<table border=1 style='border-collapse:collapse' id='tab'>"
htmlstr = htmlstr & "<tr>"
for i=0 to j
htmlstr = htmlstr & "<td>" & items2(i) & "</td>"
next
htmlstr = htmlstr & "</tr>"
while WF_Con.fetch(fldlst)>0
set tmpdoc=rdb.GetTmpDoc(fldlst)
htmlstr = htmlstr & "<tr>"
for i=0 to j
set e=tmpdoc.GetFirstItem(items(i))
if not e is nothing then
htmlstr = htmlstr & "<td>" & e.Text & "</td>"
else
htmlstr = htmlstr & "<td>" & "" & "</td>"
end if
next
htmlstr = htmlstr & "</tr>"
wend
Print htmlstr
msgbox "h3cts001:Export OK"
Exit Sub
errormsg:
Msgbox "Rule Error:" & Str(Erl) & " " & Error
End Sub