FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FW_ExcelToDBF to be extended (enhanced)
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
FW_ExcelToDBF to be extended (enhanced)
Posted: Mon Feb 08, 2021 03:25 PM

I use this function regular in some apps.

It would be great if it can be possible that we add a 2 dim. array that would/could change the headers in the excel file in order to match these of the dbf.

The dbf fields are defined, but the exels that I get are always differend than the dbf.
The sollution maybe :

aStruct := {}
DBF EXEL COLUMN
AADD(aStruct, { "Code" , "art_nummer"}) // link to Code
AADD(aStruct, { "Code" , "art_code"}) // Also link to code : there can be many more options to link to the dbf field (code)
AADD(aStruct, { "Datum" , "Datums"})
AADD(aStruct, { "Aantal" , "Quantity"})
AADD(aStruct, { "Aantal" , "menge"})
.....

The idea is that I fill the 2 dim array with Xbrowse data and past it to the FW_execltodbf

So, it will need to check if a value (2de argument = exelheader) exsist in the array in order to see if it is there. If so it needs to take the 1st argument and use that as the new header.
So several exel files could have a header colums that would link to 1 dbf field (code) in this example.

Exel headers that a not found may be omidded or just keep the exel header. The conversion will only keep the corresponding field names.

Exel = "Art_nummer, datums,menge" and would convert like
DBF = "Code,datum,aantal"

Can this be done ???

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FW_ExcelToDBF to be extended (enhanced)
Posted: Mon Feb 08, 2021 07:15 PM

Good suggestion.
We will provide this in our next version.

Regards



G. N. Rao.

Hyderabad, India
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: FW_ExcelToDBF to be extended (enhanced)
Posted: Sun Mar 07, 2021 12:15 PM

Mr. Rao,

Will it be in the new version that is upcomming ?

Thanks...

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FW_ExcelToDBF to be extended (enhanced)
Posted: Mon Mar 08, 2021 01:21 PM

Yes, please.

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FW_ExcelToDBF to be extended (enhanced)
Posted: Tue Mar 09, 2021 03:29 AM
FWH2102
FW_ExcelToDBF() --> lSuccess
Writes the contents of excel range to default alias.
Parameters:
1. [oRange] Defaults to used range in active worksheet if already open by the user.
2. [cFieldList]
a) NIL:
( i) If range has headers in first row: Copies contents of each column to
the field whose name is same as the header of the column. Skips when
no match is found.
(ii) If range has no headers:
Copies contents of excel columns from left to right into fields 1 to last.
- Char: Should be a comma delemited list of field names of the dbf.
( i) If range has headers in first row: Copies contents of columns with header
maching the contents of the list to fields with the same name. Skips when
no match is found.
(ii) If range has no headers:
Copies contents of excel columns from left to right into fields contained
in the list. Skips in case of no match.
- Two-dimensional array: First element of each item contains the field name and
the second element contains the corresponding header in the excel range or
number of the excel column or alpha-column number like "A", "C", "AB", etc.

3) [lHasHeaders]
- .T.: First row of the range is treated as headers and data is from 2nd row
- .F.: The sheet does not have any headers and all rows are treated as data.
- NIL: The function examines contents of 1st and 2nd rows, If 1st row contains
all character values and 2nd row contains atleast one non-characer value,
lHasHeaders defaults to .T.


Array can be
Code (fw): Select all Collapse
{ { "FIELD1", "header3" }, { "FIELD5", "header2" }, ... }
{ { "FIELD1", "C" }, { "FIELD5", "B" }, ... }
{ { "FIELD1", 3 }, { "field5", 2 }, ... }
Regards



G. N. Rao.

Hyderabad, India
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: FW_ExcelToDBF to be extended (enhanced)
Posted: Tue Mar 09, 2021 08:29 AM

Thank you very much !! This is very helpfull in my situation

Marc Venken

Using: FWH 23.08 with Harbour

Continue the discussion