This simple function will put the data in an active Excel sheet starting at the range indicated.
案例一
; http://www.autohotkey.com/board/topic/56987-com-object-reference-autohotkey-v11/page-7#entry394713
; http://www.autohotkey.com/board/topic/69033-basic-ahk-l-com-tutorial-for-excel/
SafeArray := ComObjArray(12, 2, 2)
SafeArray[0, 0] := 5
SafeArray[0, 1] := 4
SafeArray[1, 0] := 3
SafeArray[1, 1] := 2
x := ComObjCreate("Excel.Application")
x.visible := true
book := x.workbooks.add
x.Range("A1:B2").value := SafeArray
案例二
; http://www.autohotkey.com/board/topic/5 ... ntry394713
; http://www.autohotkey.com/board/topic/6 ... for-excel/
var := "<varContent>"
SafeArray := ComObjArray(VT_VARIANT:=12,3,1)
SafeArray[0,0] := 10
SafeArray[1,0] := var
SafeArray[2,0] := """text"""
x := ComObjCreate("Excel.Application")
x.visible := true
book := x.workbooks.add
x.Range("A1:A3").value := SafeArray
函数化
Excel_Put("A1","June 22 12:00 PM","AB",1,2,3,4,5,6,7,8,9,0,11) ; could be variables instead of static values
; Excel_Put(Range, timeLog, initLog, meatLog, meatwiLog, wifLog, adfLog, bwiLog, dmcdLog, icnLog, icsLog, prodisLog, rifLog)
Excel_Put(rng, values*)
{
Xl := ComObjActive("Excel.Application")
for key, value in values
Xl.Range(rng).Offset(key-1,0).Value := value
}