ggreen86 / XLSX-Workbook-Class

VFP Class to Create an XLSX Workbook without Excel Automation or Installed
45 stars 16 forks source link

Issue with non-$ currency symbol #75

Closed DougHennig closed 1 year ago

DougHennig commented 2 years ago

I found a couple of bugs when the Windows currency symbol is set to something other than $, such as €. First bug, in SaveVFPSettings:

*** DH 2022-08-29: fixed bug: use ", 1" to get the currency symbol
***        this.VFPSettings.Currency   = SET("CURRENCY")
           this.VFPSettings.Currency   = SET("CURRENCY", 1)

Second bug: in several places in GetGridColumnFormat, it uses a hard-coded $ rather than the actual currency symbol:

IF ',' $ toColumn.InputMask
*** DH 2022-08-29: use correct currency symbol
***        toColumn.FormatCode = '"$"#,##0' + IIF(lnLenDecPart=0, '', '.' + REPLICATE('0', lnLenDecPart))     && Change by Doug Hennig
           toColumn.FormatCode = '"' + This.VFPSettings.Currency + '"#,##0' + IIF(lnLenDecPart=0, '', '.' + REPLICATE('0', lnLenDecPart))     && Change by Doug Hennig
ELSE
*** DH 2022-08-29: use correct currency symbol
***        toColumn.FormatCode = '"$"#0' + IIF(lnLenDecPart=0, '', '.' + REPLICATE('0', lnLenDecPart))        && Change by Doug Hennig
           toColumn.FormatCode = '"' + This.VFPSettings.Currency + '"#0' + IIF(lnLenDecPart=0, '', '.' + REPLICATE('0', lnLenDecPart))        && Change by Doug Hennig
ENDIF
IF ',' $ toColumn.InputMask
*** DH 2022-08-29: use correct currency symbol
***        toColumn.FormatCode = '_("$"* #,##0' + IIF(lnLenDecPart=0, '', '.' + REPLICATE('0', lnLenDecPart)) + '_)'   && Change by Doug Hennig
           toColumn.FormatCode = '_("' + This.VFPSettings.Currency + '"* #,##0' + IIF(lnLenDecPart=0, '', '.' + REPLICATE('0', lnLenDecPart)) + '_)'   && Change by Doug Hennig
ELSE
*** DH 2022-08-29: use correct currency symbol
***        toColumn.FormatCode = '_("$"* #0' + IIF(lnLenDecPart=0, '', '.' + REPLICATE('0', lnLenDecPart)) + '_)'      && Change by Doug Hennig
           toColumn.FormatCode = '_("' + This.VFPSettings.Currency + '"* #0' + IIF(lnLenDecPart=0, '', '.' + REPLICATE('0', lnLenDecPart)) + '_)'      && Change by Doug Hennig
ENDIF
*** DH 2022-08-29: use correct currency symbol
***lcDollarSign = IIF("$" $ toColumn.Format, ""$"", "")
lcDollarSign = IIF("$" $ toColumn.Format, """ + This.VFPSettings.Currency + """, "")
ggreen86 commented 1 year ago

Doug--

As always thank you for identifying the bug and providing the solution; this is now incorporated into Release 34.

Greg