我在使用application.transpose将数据导出到excel时遇到问题

时间:2019-04-04 04:13:47

标签: arrays excel vb.net export limit

这是我使用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

1 个答案:

答案 0 :(得分:0)

类似的东西

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
相关问题