表格10000行,20多列。每个Cell都有数据(并不大)
全部生成Excel后,需要11分钟(包括简单的表格设置)我自己感觉比较慢,不知道大家的速度是多少??谢谢
全部生成Excel后,需要11分钟(包括简单的表格设置)我自己感觉比较慢,不知道大家的速度是多少??谢谢
解决方案 »
- Image.Picture = text_img.Text '图片的绝对路径付给Image.Picture 不显示图
- 询问一个显示年月日时分的控件名称?
- 经常有朋友问WINSOCK跨网段的问题,这里总结了几种情况和分别的处理方式,希望对你有用
- 如何解决用DataGrid控件来显示过多记录太慢
- 请教高手:怎么使用ADODB把第1张表的“数量”和第2张表的“数量”相加,并存到第2张表中
- 近来看一下这句sql
- 如何在VB的类模块中加一个与VB内部函数同名的函数?
- 关于拷贝独占文件的问题(NTFS格式已经可以,Fat32不行)300分
- //小问题,很急///
- 如何打印图片框中的图象?急!!1
- 大侠救命!
- 高分相赠!100分
'If the function run successfully then return true else return false
'Parameter:
'StartingCell: The position of the Starting cell
'WriteHeader:if true, write the field name, else do not write itPrivate Function CopyRecords(RST As ADODB.Recordset, WS As Worksheet, _
StartingCell As ExlCell, WriteHeader As Boolean) As Boolean
Dim SomeArray() As Variant
Dim Row As Long
Dim Col As Long
Dim Fd As ADODB.Field
Dim Recs As Long 'Recordcount
Dim iBeginRow As Integer 'In SomeArray,the begin row of the real data,not header
Dim Counter As Integer, i As Integer
On Error GoTo Err_CopyRecords 'check if recordset is opened
If RST.State <> adStateOpen Then GoTo Err_CopyRecords
' check if recordset is not empty
If RST.EOF And RST.BOF Then GoTo Err_CopyRecords
RST.MoveLast
ReDim SomeArray(0 To RST.RecordCount + 1, 0 To RST.Fields.Count)
iBeginRow = 0
If WriteHeader = True Then
' copy column headers to array
Col = 0
For Each Fd In RST.Fields
SomeArray(0, Col) = Fd.Name
Col = Col + 1
Next
iBeginRow = 1
End If
' copy recordset to SomeArray
RST.MoveFirst
Recs = RST.RecordCount
Counter = 0
For Row = iBeginRow To Recs - 1 + iBeginRow
Counter = Counter + 1
If Counter <= Recs Then i = (Counter / Recs) * 100
For Col = 0 To RST.Fields.Count - 1
SomeArray(Row, Col) = RST.Fields(Col).Value
If IsNull(SomeArray(Row, Col)) Then _
SomeArray(Row, Col) = ""
Next
RST.MoveNext
Next
' The range should have the same number of
' rows and cols as in the recordset
WS.Range(WS.Cells(StartingCell.Row, StartingCell.Col), _
WS.Cells(StartingCell.Row + RST.RecordCount + 1, _
StartingCell.Col + RST.Fields.Count)).Value = SomeArray
Exit_CopyRecords: On Error GoTo 0
CopyRecords = True
Exit Function
Err_CopyRecords: CopyRecords = False
End Function
记录集倒腾到数组,纯粹脱了裤子放屁。教你一个不用脱裤子的方法:
oSheet.Range("A1").CopyFromRecordset rs