FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse numeric formats ( To: G.N.Rao )
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
xBrowse numeric formats ( To: G.N.Rao )
Posted: Mon Oct 20, 2014 11:44 AM

Linares,

Is there any parameter to reset all the numeric formats xBrowse for Brazilian (999,999.99) standard?

If so this parameter also changes the format of the exported to Excel numbers?

Oscar Ribeiro

OASyS Informática

Fwh18.02 + xHarbour 1.2.3 + Bcc72
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse numeric formats
Posted: Tue Oct 21, 2014 09:43 AM

XBrowse (and FWH in general) support 3 kinds of numeric formats, which can be automatically reset during execution, if we do not hard-code numeric formats in our xbrowse program.

A. American format used by most countries "999,999,999.99"
E. European format "999.999.999,99", widely used in Europe
I. Indian forat: "99,99,999.99" used in Indian sub-continent.

To set / change the format, call the function:
FWNumFormat( cInternational, ; // 'A' or 'E' .or. 'I"
lUseThousandSep )

It is desirable to set the format at the beginning of the program
Example:
FWNumFormat( 'A', .t. )

XBrowse automatically builds picture clause of Numeric data on the basis of this specification, appropriate the Field Length and Field Decimals, if "we do not" provide hard-coded formats.

Regards



G. N. Rao.

Hyderabad, India
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: xBrowse numeric formats
Posted: Tue Oct 21, 2014 05:17 PM

Thanks Rao,

I used FwNumFormat ('E',. T.) and, in fact, the numbers in xBrowse already were properly disposed.

However, when exporting to Excel does not recognize the formatting.

Example: Number [12,1234] (two integers and four decimal) exported [121.234,0000] (six integers and four decimal) to excel.

Oscar Ribeiro

OASyS Informática

Fwh18.02 + xHarbour 1.2.3 + Bcc72
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: xBrowse numeric formats
Posted: Mon Oct 27, 2014 09:43 AM
No one is having this same problem when exporting numbers in European format to Excel?

Please, see this example:

Code (fw): Select all Collapse
#include 'fivewin.ch'
#include 'xbrowse.ch'

function Main()
   local oWnd, oBar, oBrw, nTotal:=0
   /*
   A. American format: "999,999,999.99"
   E. European format: "999.999.999,99"
   I. Indian   format: "99,99,999.99"
   */
   FwNumFormat( 'E', .T. )  // European Format
   DBCREATE("TESTXLS",{{"DESC   ","C",010,000},;
                       {"VAL1   ","N",010,001},;
                       {"VAL2   ","N",010,002},;
                       {"VAL3   ","N",010,003},;
                       {"VAL4   ","N",010,004},;
                       {"VAL5   ","N",010,005}})

   USE TESTXLS NEW ALIAS TESTXLS
   FOR nTotal=1 To 20
      APPEND BLANK
      REPL DESC WITH "Linha "+STRZERO(nTotal,2)
      REPL VAL1 WITH 99999 * nTotal / 777
      REPL VAL2 WITH 99999 * nTotal / 777
      REPL VAL3 WITH 99999 * nTotal / 777
      REPL VAL4 WITH 99999 * nTotal / 777
      REPL VAL5 WITH 99999 * nTotal / 777
   NEXT

   DEFINE WINDOW ownd

   DEFINE BUTTONBAR oBar OF oWnd SIZE 80,32 2007

   DEFINE BUTTON OF oBar PROMPT 'Excel' ;
          ACTION MsgMeter( { |oMeter, oText, oDlg, lEnd | ;
          Export2Excel( oBrw, oMeter, oText, oDlg, @lEnd ) } )

   DEFINE BUTTON OF oBar PROMPT 'Quit'  ACTION WndMain():End()

   SET MESSAGE OF oWnd TO '' 2007

   @ 0,0 XBROWSE oBrw OF oWnd ALIAS 'TESTXLS' AUTOCOLS CELL LINES

   // Realmente nao funciona quando exporto para o Broffice/Excel
   oBrw:aCols[2]:bFooter = {|| TRANSFORM(Field->VAL1, "@E 9.999.999,99") }
   oBrw:aCols[3]:bFooter = {|| TRANSFORM(Field->VAL2, "@E 9.999.999,99") }
   oBrw:aCols[4]:bFooter = {|| TRANSFORM(Field->VAL3, "@E 9.999.999,99") }
   oBrw:aCols[5]:bFooter = {|| TRANSFORM(Field->VAL4, "@E 9.999.999,99") }
   oBrw:aCols[6]:bFooter = {|| TRANSFORM(Field->VAL5, "@E 9.999.999,99") }

   oBrw:MakeTotals()
   oBrw:refresh()

   oBrw:CreateFromCode()

   oWnd:oClient      := oBrw

   ACTIVATE WINDOW oWnd MAXIMIZED

   CLOSE DATA

return nil

static function Export2Excel( oBrw, oMeter, oText, oDlg, lEnd )
   oBrw:ToExcel( { |n,t| oMeter:nTotal := t, ;
                         oMeter:Set( n ), ;
                         oText:SetText( Str(n) + '/' + Str(t) ), ;
                         oDlg:Update(), .t. } )
return nil
Oscar Ribeiro

OASyS Informática

Fwh18.02 + xHarbour 1.2.3 + Bcc72
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: xBrowse numeric formats
Posted: Tue Oct 28, 2014 06:18 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341

Continue the discussion