数据有15万行左右,
用下面的代码导入输入实在是太慢了,就像假死了一样,有没有快速一些的方法呢?
Dim v1 As WinForm.NumericComboBox = e.Form.Controls("NumericComboBox1")
Dim v2 As WinForm.NumericComboBox = e.Form.Controls("NumericComboBox2")
If v1.Value Is Nothing Then
MessageBox.show("必须选择年份")
Return
End If
If v2.Value Is Nothing Then
MessageBox.show("必须选择月份")
Return
End If
Dim t1 As Date = Date.Now
Dim tb As Table = Tables(e.Form.Name & "_table1")
Dim nt As Integer = v1.Value
Dim y As Integer = v2.Value
Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog,就是打开
dlg.Filter= "Excel| *.xls;*.xlsx" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim book As new XLS.Book(dlg.FileName)
Dim sheet As XLS.Sheet = book.Sheets(0) '第一个表
Dim bar As WinForm.ProgressBar = e.Form.Controls("ProgressBar1")
bar.Minimum= 0
bar.Maximum =sheet.Rows.Count
Dim nma() As String = {"catd","catz","catx","hotkeyword","keyfen","szkey","total","mobile","web","jz","ppc","click","roas"}
DataTables("ST11Keyword").StopRedraw()
tb.StopRedraw()
For n As Integer = 3 To sheet.Rows.Count - 1
Dim v As Integer = v + 1
bar.Value = v
Dim dr As DataRow = DataTables("ST11Keyword").AddNew()
For i As Integer = 0 To sheet.Cols.Count - 1
dr(nma(i)) = Sheet(n,i).Value
Next
dr("年") = nt
dr("月") = y
Next
DataTables("ST11Keyword").Save
DataTables("ST11Keyword").LoadFilter = "_identify = 0"
DataTables("ST11Keyword").Load
DataTables("ST11Keyword").ResumeRedraw()
tb.ResumeRedraw()
msgbox("ok")
End If
MessageBox.Show("计算结束, 耗时: " & (Date.Now - t1).TotalSeconds & "秒")