日期:2014-05-17 浏览次数:21082 次
set rs=server.CreateObject("adodb.recordset") set dit=Server.CreateObject ("Scripting.Dictionary") rs.Open "select * from [工作表]",conn,1,1 while not rs.EOF dept=rs("生产部门") arrdept=split(dept,"|") fdept="|"&rs("完成部门")&"|" for i=0 to ubound(arrdept) if isempty(dit(arrdept(i))) then arr=array(0,0,0)'键值为数组,第一项完成的,第二项未完成,第三项作业数 else arr=dit(arrdept(i)) end if arr(2)=arr(2)+1'作业数+1 if instr(fdept,"|"&arrdept(i)&"|")=0 then'未包含在完成部门 arr(1)=arr(1)+1 else arr(0)=arr(0)+1 end if dit(arrdept(i))=arr next rs.MoveNext wend rs.Close:set rs=nothing:conn.Close:set conn=nothing keys=dit.Keys response.Write "<table><tr><td>部门</td><td>作业完成数</td><td>作业未完成数量</td><td>作业合计</td></tr>" for i=0 to ubound(keys) arr=dit(keys(i)) response.Write "<tr><td>"&keys(i)&"</td><td>"&arr(0)&"</td><td>"&arr(1)&"</td><td>"&arr(2)&"</td></tr>" next response.Write "</table>"