Xbrowse Toexcel number conversion

Xbrowse Toexcel number conversion

Postby mauri.menabue » Tue Dec 15, 2009 7:58 am

Hello

I remarked that when I use xbrowse Toexcel() in excel the numer are always wrong .
I try to use xbrNumFormat() without success .

It's a xbrowse bug ?
Fwh 9.11 November

This is test program by another Maurizio

Code: Select all  Expand view

#include 'fivewin.ch'
#include 'xbrowse.ch'

static oFont, ovFont,oWnd,oBrw

function main()

   Local aDbf := {}
   Local nX := 1
   Local cPic := "@ZE 999999.9999"

   ferase("NUMBER.DBF")
   
   AADD (aDbf, {"NUM_1"   ,"N", 12, 3 })
   AADD (aDbf, {"NUM_2"   ,"N", 12, 3 })
   AADD (aDbf, {"NUM_3"   ,"N", 12, 3 })
   dbcreate("NUMBER", aDbf)
 
   xbrNumFormat( "E", .t. )  // "E" for European, "A" for American and others
                             // .t. for showing thousand separators

   use number
   
   FOR nX := 1 to 10
       dbappend()
       field->NUM_1 := nX * 0.1
       field->NUM_2 := nX * 10
       field->NUM_3 := nX * 100
   NEXT
   dbgotop()
   DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12
   DEFINE FONT oVfont NAME 'TAHOMA' SIZE 0,-12 NESCAPEMENT 900

   DEFINE WINDOW oWnd  MENU MainMenu()
   oWnd:SetFont( oFont )

   @ 0,0 XBROWSE oBrw ;
      COLUMNS 'NUM_1', 'NUM_2', 'NUM_3' ;
      PICTURE cPic,cPic,cPic ;
      OF oWnd ;
      ALIAS 'NUMBER' ;
      LINES CELL
   
   
   oBrw:CreateFromCode()
   oWnd:oClient := oBrw

   SET MESSAGE OF oWnd TO "XBrowse " 2007

   ACTIVATE WINDOW oWnd
     

return nil
//===========================
Static Function MAinMenu()
Local oPop
   MENU oPop 2007
      MENUITEM "Excel" ACTION oBrw:ToExcel()
      MENUITEM "Exit" ACTION oWnd:end()
   ENDMENU
Return oPop
 



Regards Maurizio Menabue
User avatar
mauri.menabue
 
Posts: 155
Joined: Thu Apr 17, 2008 2:38 pm

Re: Xbrowse Toexcel number conversion

Postby Antonio Linares » Tue Dec 15, 2009 11:12 pm

Maurizio,

At present the number export format is hard coded with 2 decimal places.
The methods are modified in version 9.12 to adopt the actual decimal places in the column’s picture format.

You can replace the code in line no: 6097 ( fwh 9.11 )
Code: Select all  Expand view

cFormat  += If( lxlEnglish, ".00", ",00"  )
 

With
Code: Select all  Expand view

               cFormat  += If( lXlEnglish, '.', ',' ) + StrTran( StrTran( SubStr( oCol:cEditPicture, ;
                           At( '.', oCol:cEditPicture ) + 1 ), '9', '0' ), '#', '0' )
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 100 guests