附上我的完整测试代码$excel=ObjCreate("excel.application")
$excel.visible=False
$wb=$excel.workbooks.open(@ScriptDir&"\1.xlsx")
_ReplaceExcelArea($wb.activesheet,"a1:l18","1","-")
$wb.save
$wb.close
$excel.quit
MsgBox(0,"","OK")
Func _ReplaceExcelArea($oexcel,$range="A1",$lookupvalue="",$replacevalue="",$skipformulacell=1)
Dim $arr,$n,$i
With $oexcel.range($range)
$arr=.formula
For $n=0 To UBound($arr)-1
For $i=0 To UBound($arr,2)-1
If $skipformulacell=0 Or StringLeft($arr[$n][$i],1)<>"=" Then $arr[$n][$i]=StringReplace($arr[$n][$i],$lookupvalue,$replacevalue)
Next
Next
.formula=$arr
EndWith
EndFunc
|