did somebody use LibXL ( http://www.libxl.com ) with harbour
LibXL and harbour
Moderator: Rathinagiri
- AUGE_OHR
- Posts: 2117
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
LibXL and harbour
have fun
Jimmy
Jimmy
Re: LibXL and harbour
I'm using xmlxclass.prg for reading Excel files.
It's possible to use it to write data to xlsx
It's possible to use it to write data to xlsx
- Attachments
-
- XLSXClass.zip
- (11.31 KiB) Downloaded 562 times
Re: LibXL and harbour
I can post a piece of my code using it if you want...
Re: LibXL and harbour
Hello MOL
if you provide an example of use, I will be happy to study it
there are 2-3 different xlsx versions here on the forum
I'm mainly interested in reading xlsx, xls
Best regards, George
if you provide an example of use, I will be happy to study it
there are 2-3 different xlsx versions here on the forum
I'm mainly interested in reading xlsx, xls
Best regards, George
- AUGE_OHR
- Posts: 2117
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: LibXL and harbour
hi,
Question : can you run > 100000 Row
every Sample of CODE can help, thx
Question : can you run > 100000 Row
have fun
Jimmy
Jimmy
Re: LibXL and harbour
I don't know limits. I'll try to post piece of my code tomorrow
Re: LibXL and harbour
Piece of my code to get data from sheet
Code: Select all
function PobierzFakture
local cPlik
local oExcel := NIL
local oSheet1 := NIL
local w, i, k
local aKonwersja := { => }
local cKolumna := ""
local nKolumnaDaty := 0
local aKeys := {}
local nCzasKonwersji := hb_MilliSeconds()
local dDataPozycji := 0d0
local xDane
local cTyp
OknoGlowne.B_Faktury.ItemCount := 0
OknoGlowne.B_Pozycje.ItemCount := 0
ahFaktury := {=>}
aFaktury := {}
aPozycje := {}
aKonwersja := { ;
"DOSTAWA" => { "NrSklepu" , 0, .t.},;
"NR FRY" => { "NrFaktury", 0, .t.},;
"EAN" => { "EAN" , 0, .t.},;
"NAZWA" => { "Nazwa" , 0, .f.},;
"ILOSC" => { "Ilosc" , 0, .t.},;
"WARTOSC" => { "WartNetto", 0, .t.},;
"VAT" => { "WartVAT" , 0, .f.},;
"STARYKOD" => { "OldMatNum", 0, .f.},;
"RRP" => { "RRP" , 0, .f.},;
"NAZWA1" => { "Nazwa1" , 0, .f.} ;
}
aKeys := hb_hKeys(aKonwersja)
if !empty(cPlik:=GetFile( { {'Arkusz nowy format Excel XLSX','*.xlsx'} },'Wybierz plik z fakturą' , cFolderOdczytu, .f. , .t. ) )
OknoGlowne.T_Plik.Value := cPlik
cFolderOdczytu := HB_FNameDir(cPlik)
BEGIN INI FILE "konwerter.ini"
SET SECTION "KONWERTER" ENTRY "FolderOdczytu" TO cFolderOdczytu
END INI
else
return .f.
endif
pozycje->(DBZapArea())
//WlaczWaitWindow("Trwa pobieranie faktur. Operacja może potrwać długo...")
OknoGlowne.L_Status.Value := "Trwa pobieranie faktur. Operacja może potrwać długo..."
OknoGlowne.L_Status.FontColor := {255,0,0}
OknoGlowne.B_Pozycje.ItemCount := 0
OknoGlowne.B_Faktury.ItemCount := 0
oExcel := WorkBook():New()
BEGIN SEQUENCE with {||break()}
oExcel:Read(cPlik)
RECOVER
OknoGlowne.L_Status.Value := "Błąd podczas odczytu pliku XLSX z fakturami. Być może jest za długi?"
MsgStop("Błąd podczas odczytu pliku XLSX z fakturami. Być może jest za długi?")
return .f.
END SEQUENCE
BEGIN SEQUENCE with {||break()}
cSheet1Name := oExcel:aWorkSheetNames[1]
oSheet1:= oExcel:WorkSheet(cSheet1Name)
RECOVER
OknoGlowne.L_Status.Value := "Brak dostępu do arkusza z fakturą w pliku XLSX. Operacja przerwana"
MsgStop("Brak dostępu do arkusza z fakturą w pliku XLSX. Operacja przerwana")
return .f.
END SEQUENCE
nLiczbaWymaganychPol := 0
for each cKolumna in hb_hKeys(aKonwersja)
// musimy wyzerować indeksy odszukanych pól z poprzedniej pętli
aKonwersja[ cKolumna ][2] := 0
if aKonwersja[ cKolumna ][3] == .T.
nLiczbaWymaganychPol++
endif
next
// przypisujemy numery kolumn w arkuszu do poszczególnych pól
for k:=1 to len(oSheet1:aData[1])
if !empty(oSheet1:aData[1,k])
cKolumna := upper(hb_UTF8ToStr(oSheet1:aData[1, k]))
// 20210928 if cKolumna == "BILLING DATE"
if cKolumna == "DATA"
nKolumnaDaty := k
endif
if hb_hPos(aKonwersja, cKolumna) > 0
aKonwersja[ cKolumna ][2] := k
if aKonwersja[ cKolumna ][3] == .T.
nLiczbaWymaganychPol--
endif
endif
endif
next k
if nKolumnaDaty == 0
MsgStop("W wybranym pliku XLSX z fakturą nie odnaleziono daty dokumentu. Operacja przerwana!")
return .f.
endif
if nLiczbaWymaganychPol>0
MsgStop("W wybranym pliku XLSX z fakturą nie odnaleziono wszystkich wymaganych kolumn do konwersji. Operacja przerwana!")
return .f.
endif
w := 2
k := 1
aPozycje := {}
select("pozycje")
for w:=2 to len(oSheet1:aData)
if empty( oSheet1:aData[w, 1] )
exit
endif
append blank
for each cKolumna in aKeys
k := aKonwersja[ cKolumna ][2]
if k>0
// kolumna do zaimportowania
xDane := oSheet1:aData[w, k]
cPole := aKonwersja[ cKolumna ][1]
cTyp := valtype(&cPole)
if (cTyp == "N") .and. (valtype(xDane) == "C")
xDane := val(xDane)
endif
begin sequence with {||break()}
replace;
&cPole with xDane
recover
MsgInfo("Błąd w wierszu: "+hb_ntos(w)+chr(10)+;
"Pominięto pole: "+cPole+" z odczytaną wartością " +hb_valtoexp(xDane))
end sequence
endif
next i
if hb_hPos(ahFaktury, pozycje->NrFaktury ) == 0
dDataPozycji := stod("19000101") + oSheet1:aData[w, nKolumnaDaty] - 2
ahFaktury[ pozycje->NrFaktury ] := { pozycje->NrSklepu,;
pozycje->NrFaktury,;
dDataPozycji,;
0,;
0,;
0,;
0 }
endif
ahFaktury[ pozycje->NrFaktury ][4] += pozycje->(WartNetto+WartVAT)
ahFaktury[ pozycje->NrFaktury ][5] += pozycje->WartNetto
ahFaktury[ pozycje->NrFaktury ][6] += pozycje->WartVAT
ahFaktury[ pozycje->NrFaktury ][7] += 1
next w
aFaktury := {}
cFaktura := ""
for each cFaktura in hb_hKeys(ahFaktury)
aAdd(aFaktury, ahFaktury[cFaktura])
next
OknoGlowne.B_Faktury.ItemCount := len(ahFaktury)
f := min(1,len(ahFaktury))
OknoGlowne.B_Faktury.Value := f
oSheet1 := NIL
oExcel := NIL
//WAIT CLEAR
nCzasKonwersji := (hb_MilliSeconds() - nCzasKonwersji)/1000
OknoGlowne.L_Status.Value := "Zaimportowano faktury, czas wykonania: "+ hb_ntos(nCzasKonwersji)+" sek."
OknoGlowne.L_Status.FontColor := {0,128,0}
return
-
Red2
- Posts: 282
- Joined: Sat May 18, 2019 2:11 pm
- DBs Used: Visual FoxPro, FoxPro
- Location: United States of America
Re: LibXL and harbour
Hi Mol,
Can the Harbour code in your XLSXClass.zip be adapted for "Official" HMG.
It seem incompatible "as is" in 3.4.4.
The Problem:
The current hblibxlsxwriter solution I use is apparently 32-bit only.
I want to find some (non VBA) solution to create/write an .XLSX file from within the new 64-bit HMG.3.6.
Anyone's ideas would be most greatly appreciated.
======================================================
¿Se puede adaptar el código Harbour en su XLSXClass.zip para "Official" HMG?
Parece incompatible "tal cual" en 3.4.4.
El problema:
La solución hblibxlsxwriter actual que uso aparentemente es solo de 32 bits.
Quiero encontrar alguna solución (non VBA) para crear/escribir un archivo .XLSX desde el nuevo 64-bit HMG.3.6.
Las ideas de cualquiera serían muy apreciadas.
Thank you!
Can the Harbour code in your XLSXClass.zip be adapted for "Official" HMG.
It seem incompatible "as is" in 3.4.4.
The Problem:
The current hblibxlsxwriter solution I use is apparently 32-bit only.
I want to find some (non VBA) solution to create/write an .XLSX file from within the new 64-bit HMG.3.6.
Anyone's ideas would be most greatly appreciated.
======================================================
¿Se puede adaptar el código Harbour en su XLSXClass.zip para "Official" HMG?
Parece incompatible "tal cual" en 3.4.4.
El problema:
La solución hblibxlsxwriter actual que uso aparentemente es solo de 32 bits.
Quiero encontrar alguna solución (non VBA) para crear/escribir un archivo .XLSX desde el nuevo 64-bit HMG.3.6.
Las ideas de cualquiera serían muy apreciadas.
Thank you!
Re: LibXL and harbour
It's harbour code so it shouldn't be problem.
My main computer is out of order and I'm sending it today to hp service.
My main computer is out of order and I'm sending it today to hp service.