|
楼主 |
发表于 2010-11-13 14:46:18
|
显示全部楼层
本帖最后由 pchome2000 于 2010-11-13 14:47 编辑
;横向写入数组,修改自 _ExcelWriteSheetFromArray 函数。
Func _ExcelWriteSheetRowFromArray($oExcel, ByRef $aArray, $iStartRow = 1, $iStartColumn = 1, $iRowBase = 1, $iColBase = 1)
; Test inputs
If Not IsObj($oExcel) Then Return SetError(1, 0, 0)
If $iStartRow < 1 Then Return SetError(2, 0, 0)
If $iStartColumn < 1 Then Return SetError(2, 1, 0)
If Not IsArray($aArray) Then Return SetError(3, 0, 0)
Local $iDims = UBound($aArray, 0), $iLastRow = UBound($aArray, 1) - 1, $iLastColumn = UBound($aArray, 2) - 1
If $iDims <> 2 Then Return SetError(3, 1, 0)
If $iRowBase > $iLastRow Then Return SetError(4, 0, 0)
If $iColBase > $iLastColumn Then Return SetError(4, 1, 0)
Local $iCurrCol
$iCurrCol = $iStartColumn
For $r = $iRowBase To $iLastRow
For $c = $iColBase To $iLastColumn
$oExcel.Activesheet.Cells($iStartRow,$iCurrCol).Value = $aArray[$r][$c]
$iCurrCol += 1
Next
;$iStartRow += 1
Next
Return 1
EndFunc ;==>_ExcelWriteSheetFromArray |
|