详细查阅UDF里关于EXCEL管理的相关文章,这些UDF很强。
或者用一种简便的方法,即在普通文本文档中书写:字符A+TAB键+字符B,保存为.xls,所得结果为相邻单元格内的字符A和字符B,TAB为Chr(9)_Main()
Func _Main()
Local $Excel = @ScriptDir & "\Test.xls"
Local $r = _MakeExcel($Excel)
If $r=0 Then
MsgBox(0+16,"错误","Excel文档创建失败")
EndIf
Exit
EndFunc ;==>_Main
Func _MakeExcel($Excel)
Local $Array[5][2] = [[1, 'a'],[2, 'b'],[3, 'c'],[4, 'd'],[5, 'e']]
Local $i, $j
Local $ExcelHdl = FileOpen($Excel, 2)
If $ExcelHdl = -1 Then Return 0
For $i = 0 To UBound($Array, 1) - 1
Local $s = ""
For $j = 0 To UBound($Array, 2) - 1
$s = $s & $Array[$i][$j] & Chr(9)
Next
$s = StringTrimRight($s, 1)
FileWriteLine($ExcelHdl, $s)
Next
FileClose($ExcelHdl)
Return 1
EndFunc ;==>_MakeExcel
|