FW_ExcelToDBF to be extended (enhanced)

FW_ExcelToDBF to be extended (enhanced)

Postby Marc Venken » Mon Feb 08, 2021 3: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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1429
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: FW_ExcelToDBF to be extended (enhanced)

Postby nageswaragunupudi » Mon Feb 08, 2021 7:15 pm

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

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10628
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FW_ExcelToDBF to be extended (enhanced)

Postby Marc Venken » Sun Mar 07, 2021 12:15 pm

Mr. Rao,

Will it be in the new version that is upcomming ?

Thanks...
User avatar
Marc Venken
 
Posts: 1429
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: FW_ExcelToDBF to be extended (enhanced)

Postby nageswaragunupudi » Mon Mar 08, 2021 1:21 pm

Yes, please.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10628
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FW_ExcelToDBF to be extended (enhanced)

Postby nageswaragunupudi » Tue Mar 09, 2021 3: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: Select all  Expand view

{ { "FIELD1", "header3" }, { "FIELD5", "header2" }, ... }
{ { "FIELD1", "C" }, { "FIELD5", "B" }, ... }
{ { "FIELD1", 3 }, { "field5", 2 }, ... }
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10628
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FW_ExcelToDBF to be extended (enhanced)

Postby Marc Venken » Tue Mar 09, 2021 8:29 am

Thank you very much !! This is very helpfull in my situation
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1429
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Jimmy and 23 guests