我在VBA中写了以下内容来解决这个缺点......
Public Function returnresults()
Dim lResultsize As Long
Dim sBigblock As Variant
Dim lLow As Long
Dim lHigh As Long
Dim vTemp As Variant
Dim i As Long
Dim j As Long
Dim lBigrow As Long
Dim lFullresults As Long
rinterface.RRun "abc<-length(vbaget[,1])"
lFullresults = rinterface.GetRExpressionValueToVBA("abc")
lResultsize = lFullresults
If lResultsize > 1048575 Then
MsgBox "Results exceed 1,048,575 rows. Excess will be dropped."
lResultsize = 1048575
End If
sBigblock = ThisWorkbook.Sheets("results").Range("a2:m" & lResultsize + 1)
lHigh = lResultsize
lLow = 1
If lResultsize > 3000 Then lHigh = 3000
lBigrow = 1
Do While lHigh <= lResultsize And lLow < lHigh
rinterface.RRun "temp<-vbaget[" & lLow & ":" & lHigh & ",]"
vTemp = rinterface.GetArrayToVBA("temp")
For i = 0 To UBound(vTemp, 1)
For j = 1 To 13 'This is number of columns in array it could be dynamic
sBigblock(lBigrow, j) = vTemp(i, j - 1)
Next j
lBigrow = lBigrow + 1
Next i
lLow = lHigh + 1
lHigh = lLow + 2999
If lHigh > lResultsize Then lHigh = lResultsize
Loop
ThisWorkbook.Sheets("results").Range("a2:m" & lResultsize + 1) = sBigblock
End Function