#include <Array.au3>
Local $sFilepath = "d:\rm.xls"
Local $oExcel = ObjGet($sFilepath)
Local $aName[1][1]
If @error = 1 Then
MsgBox(0, "错误!", "无法创建对象!")
Exit
ElseIf @error = 2 Then
MsgBox(0, "错误!", "文件不存在!")
Exit
EndIf
$o_Dic = ObjCreate("scripting.dictionary")
With $oExcel.activesheet
For $o_Rng In .range("a2", .cells(.rows.count, 1).end(3))
If $o_Dic.exists($o_Rng.value) Then
$o_Dic($o_Rng.value) = $o_Dic($o_Rng.value) + 1
Else
$o_Dic($o_Rng.value)=1
EndIf
Next
EndWith
$oExcel.close(false)
ReDim $aName[$o_Dic.count][2]
$a_Arr=$o_Dic.keys
For $i=0 To UBound($a_Arr)-1
$aName[$i][0] = $a_Arr[$i]
$aName[$i][1] = $o_Dic($a_Arr[$i])
Next
_ArrayDisplay($aName)
这个可以了 |