B4J Question Problem with Jpoi and large files

Giacomo

Active Member
Licensed User
Longtime User
Help me
if i open excel file with 2.000 rows i have no problem
B4X:
Sub Leggi_excel(Dir As String ,File_excel As String)
    Start=DateTime.Now
    Leggi.InitializeExistingAsync("Lettura",Dir,File_excel,"")
    
End Sub
B4X:
Sub Lettura_ready(Success As Boolean)
    LogDebug("Lettura Finita")
    Dim Tempo_di_lettura As Double=DateTime.Now-Start
    Tempo_di_lettura=Tempo_di_lettura/1000
    LogDebug ("Tempo di lettura " & Tempo_di_lettura & " Secondi")
    'Legge il file selezionato e scrive Variabile Elenco (20)
    Elenca
    'Scrive il TreeView
    Costruisci_tree.Riempi_Tree(Main.TreeWiew_01,Caratteristiche_excell)
end sub

but if I open larger files about 100.000 lines nothing happens
What can I do ?
 

Giacomo

Active Member
Licensed User
Longtime User
I try but too big 70Mb 420.000 rows and 32 column

WS_ROWS.xlsx
The uploaded file is too large for the server to process.
the question is ?I can read it in blocks ?

My final target is convert it to Sqlite Db
 
Upvote 0

udg

Expert
Licensed User
Longtime User
If anything else fails, you could save it as several smaller files and import them one after the other in your DB.
Tedious but feasible..
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Giacomo

Active Member
Licensed User
Longtime User
If anything else fails, you could save it as several smaller files and import them one after the other in your DB.
Tedious but feasible..

Frankestain Junior.jpg


it can be done
there are 150 Excel files every month
dividing them (e.g. x10) they are 1500 excel every month

too tiring :eek:
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Agreed. I understood it as a one-timer import.
 
Upvote 0

Giacomo

Active Member
Licensed User
Longtime User
Test it with InitializeExisting instead of InitializeExistingAsync.

Increase the VM heap size:
B4X:
#VirtualMachineArgs: -Xms4096m -Xmx4096m
My System is 32 bit therefore
#VirtualMachineArgs: -Xms1024m -Xmx1024m

B4X:
Sub Leggi_excel(Dir As String ,File_excel As String)
    Start=DateTime.Now
    'Leggi.InitializeExistingAsync("Lettura",Dir,File_excel,"")
    Leggi.InitializeExisting(Dir,File_excel,"")
   
End Sub
The result is
java.lang.OutOfMemoryError: Java heap space ........
 
Upvote 0

Giacomo

Active Member
Licensed User
Longtime User
All clear thanks

in the end the only solution seems to be that of udg :rolleyes::rolleyes::rolleyes::rolleyes:
If anything else fails, you could save it as several smaller files and import them one after the other in your DB.
Tedious but feasible..
 
Upvote 0

roerGarcia

Active Member
Licensed User
Longtime User
May be this

Excel macro to navigate all the files:
Sub AbrirArchivos()

'Paso 1: Declarar las variables

Dim Archivos As String


'Paso 2: Especificar una carpeta y el tipo de archivo que buscamos
'en este caso la carpeta se llama "temporal" y el tipo de dato es "xlsx"


Archivos = Dir("C:\temporal\*.xlsx")
Do While Archivos <> “”


'Paso 3: Abrir los libros uno por uno

Workbooks.Open "C:\temporal\" & Archivos

' Paso 4: se coloca el código que se quiere correr
'en el caso de este ejemplo se corre el código que aparece a continuación
'el cual sirve para borrar el contenido de la celda A1

[B]Range("a1").ClearContents ' not  this of course[/B]

'Paso 5: Cuadro de mensaje, cerrar y guardar cambios

MsgBox ActiveWorkbook.Name

ActiveWorkbook.Close SaveChanges:=True

'Paso 6: buscar más archivos en la carpeta para volver seguir la secuencia

Archivos = Dir
Loop

End Sub
 
Upvote 0

RWK

Member
Licensed User
You could try it the other way around.....

export in Excel to csv.... then use this with b4x...

something like that:

Code:
Sub BuildDatevFile(ExFile As String)

Open ExFile For Output As #1

    'Kopfdaten
    Print #1, sDatevKopf
    'Buchungsdaten
    For x = 1 To tabDatev.UsedRange.EntireRow.Count
        For y = 1 To 116
            P tabDatev.Cells(x, y)
        Next y
        Print #1, ""
    Next x
Close #1
End Sub

Sub P(Datenfeld As String)
    If Datenfeld = "" Then
        Print #1, Chr(34) & Chr(34) & Chr(59);
    Else
        Print #1, Datenfeld & Chr(59);
    End If
End Sub

Grüße
Rainer
 
Upvote 0
Top