Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   .NET Office Automation (http://www.xtremevbtalk.com/-net-office-automation/)
-   -   How load fast Excell file to listview? (http://www.xtremevbtalk.com/-net-office-automation/327618-load-fast-excell-file-listview.html)

Andres128 05-14-2015 03:48 PM

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 :D:D:D

Flyguy 05-18-2015 02:38 AM

Why do you first build a big text string?
Why not add every line to the listview directly??


All times are GMT -6. The time now is 05:55 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.