MS Excel shows "nnnn," for numbers with SET DECIMALS TO 0.

KB-20200421-01

Version

<XFRX 19.2.0

Cause

SET DECIMALS TO 0.

Symptoms

MS Execel shows "125," for number 125.45.

Workaround

Use a call back function:

#DEFINE XFRX_FORMATCOL_FNAME      1 && Field Name
#DEFINE XFRX_FORMATCOL_FTYPE      2 && Field Type
#DEFINE XFRX_FORMATCOL_XLSFORMAT  8 && XLS Format

m.liErr=XFRX_CopyToXLSX("cursor name", "c:\folder\file.xlsx", "copytoxlsfccallback_static", "sheet name", .T., .T.)

PROCEDURE copytoxlsfccallback_static
LPARAM m.laFields
EXTERNAL ARRAY m.laFields
FOR m.lii=1 TO ALEN(m.laFields, 1)
    IF INLIST(m.laFields(m.lii, XFRX_FORMATCOL_FTYPE), "B", "F", "N", "Y") AND SET("DECI")=0 
       m.laFields(m.lii, XFRX_FORMATCOL_XLSFORMAT)=CHRTRAN(m.laFields(m.lii, XFRX_FORMATCOL_XLSFORMAT), ".", "")
    ENDIF
NEXT
ENDPROC