这是我使用application.transpose将数据从数据库导出到excel的代码,但我搜索它有64000行或数组的限制如何导出大于其限制的数据?
这是我的代码......
Dim dc As System.Data.DataColumn
Dim colIndex As Integer = 0
Dim rowIndex As Integer = 0
Dim adt As New MySqlDataAdapter("My Query", "My connection")
Dim dt As New DataTable
adt.Fill(dt)
'Nombre de mesures
Dim Nbligne As Integer = dt.Rows.Count
'(Write column headers and data)
For Each dc In dt.Columns
colIndex = colIndex + 1
sheet.Cells(3, colIndex).Resize(Nbligne, ).Value = app.Application.transpose(dt.Rows.OfType(Of DataRow)().[Select](Function(k) CObj(k(dc.ColumnName))).ToArray())
Next
这样的事情
Function TransposeArray1D(ByVal arr As Variant) As Variant
Dim tempArray As Variant
ReDim tempArray(LBound(arr, 1) To UBound(arr, 1), LBound(arr(0)) To UBound(arr(0)))
For y = LBound(arr, 1) To UBound(arr, 1)
For x = LBound(arr(0)) To UBound(arr(0))
tempArray(y, x) = arr(y)(x)
Next x
Next y
TransposeArray1D = tempArray
End Function
Function TransposeArray2D(ByVal arr As Variant) As Variant
Dim tempArray As Variant
ReDim tempArray(LBound(arr, 2) To UBound(arr, 2), LBound(arr, 1) To UBound(arr, 1))
For x = LBound(arr, 2) To UBound(arr, 2)
For y = LBound(arr, 1) To UBound(arr, 1)
tempArray(x, y) = arr(y, x)
Next y
Next x
TransposeArray2D = tempArray
End Function
Function TransposeArrayIndex(ByVal arr As Variant, ByVal nTh As Long) As Variant
Dim tempArray As Variant
ReDim tempArray(0 To UBound(arr, 2))
For y = LBound(arr, 2) To UBound(arr, 2)
tempArray(y) = arr(nTh, y)
Next y
TransposeArrayIndex = tempArray
End Function