B4J Question How to quickly search for text in an excel file

supriono

Member
Licensed User
Longtime User
dear all,
i have same problem search or campere string in excel file

with this function the application runs work but the response is too slowly
in excel file i have 90.000-150.000 row with 30 column


B4X:
Sub ambil_dt2(value As String,file_path As String,file_name As String)
    Dim list2 As List
    Dim i As Boolean
    list2.Initialize
    Dim wb As PoiWorkbook
    wb.InitializeExisting(file_path,file_name,"")
    Dim sheet1 As PoiSheet=wb.GetSheet(0)
    For Each r As PoiRow In sheet1.Rows
        Dim rowcells As List:rowcells.Initialize
        i=0
        For Each c As PoiCell In r.Cells
            rowcells.Add(c.Value):If c.Value=value Then i=1
        Next
        If i=1 Then Exit
    Next
    
    If i=0 Then
        Log("Not Found")
    else if i=1 Then
        Log("Fount Text")
        Log(rowcells)
    End If
End Sub

maybe same one sugestion to me how to make fast search.
excel files from third parties, so I can't change their data
 

Daestrum

Expert
Licensed User
Longtime User
Does the data you are searching for only appear in a specific column?
If it does then only searching that column would speed up your code, as you currently search every cell in every row.
 
Upvote 0

supriono

Member
Licensed User
Longtime User
Does the data you are searching for only appear in a specific column?
If it does then only searching that column would speed up your code, as you currently search every cell in every row.

column number 3 for compare string....how to searching spesific column?
 
Upvote 0

supriono

Member
Licensed User
Longtime User
Read all relevant cells once and store their the values in a map (as keys). You will then be able to make very quick searches.
thanks for your replay erel.do you have link about it? i mean example use map
 
Upvote 0
Top