我正在编写一个函数,用于在grid.net上将数据从gridview导出到Excel这个方法:
Call consultaPlanilha()
Dim i, j As Integer 'CONTADORES
ReDim vetPontos(GridPontos.Rows.Count - 2, 1)
For i = 0 To GridPontos.Rows.Count - 2
For j = 0 To 1
vetPontos(i, j) = CDbl(GridPontos.Item(j, i).Value)
xlw.Application.Cells(i + 3, j + 2).Value = vetPontos(i, j)
Next
Next
xlw.Save()
这需要很长时间才能处理大量数据。是否有更快的方法可以立即将大量数据写入Excel?用范围做某事会更快吗?
答案 0 :(得分:0)
你知道你可以这样做:
Dim vetPontos() as Variant
ReDim vetPontos(1 to 100, 1 to 20)
For i=1 to 100
For j=1 to 20
// fill in vetPontos(i,j)
Next j
Next i
Range("A1").Resize(100,20).Value = vetPontos