View Single Post
 
Old 05-14-2015, 03:48 PM
Andres128 Andres128 is offline
Newcomer
 
Join Date: May 2015
Posts: 1
Question How load fast Excell file to listview?

Hello friends this respected forum!

I have a problem is that I have an excel file with 10,000 rows, like this:

Hello friends this respected forum! :thumb::thumb::thumb:

I have a problem is that I have an excel file with 10,000 rows, like this:

Code:
F1 B1 D1
aa bb cc
I have this code, it works but it is slow to load in a listview, you could help me improve my code, I really appreciate what I have tried many ways and I can not get it to load faster.

Code:
Dim oExcel As Object = CreateObject("Excel.Application")
Dim oBook As Object = oExcel.Workbooks.Open(mypatch)
Dim oSheet As Object = oBook.Worksheets(1)
Dim range As Excel.Range = oSheet.UsedRange
Dim number As Integer
Dim celd_B, celd_D, celd_F As String
Me.Cursor = Cursors.WaitCursor

For i = 1 To range.Rows.Count

number = i + 1
celd_B = oSheet.Range("B" & number).Value
celd_D = oSheet.Range("D" & number).Value
celd_F = oSheet.Range("F" & number).Value

If Not celd_B = "" And Not celd_D = "" And Not celd_F = "" And celd_D >= 1000 Then

result.Text += celd_B & "#" & celd_D & "#" & celd_F & "#" & vbNewLine 'PROBLEM HERE SLOW LOAD :(
               

End If
Next


result.Text = result.Text.TrimEnd

'Show listview:
Dim items() As ListViewItem = (From line In result.Lines _
                                 Select New ListViewItem(line.Split("#"c))).ToArray
            ListadoView.Items.AddRange(items)
No more thank you very much for your time and for helping to solve this problem.

Bye and greetings brothers
Reply With Quote