Page 1 of 1

xbrowse to excel

PostPosted: Tue Dec 09, 2014 11:46 am
by Romeo
Ciao
Ho un problema con Xbrowse e la trasformazione in Excel dei campi numerici con virgola.

Mi spiego meglio, se genero un file excel con campi numerici interi.... tutto ok

Se invece il campo numerico ha dei decimali, quando genero il relativo campo excel, invece che la virgola mi esce il puntino e quindi non riesco poi a fare operazioni numeriche su tale campo excel.

Ho provato a modificare un po di cose all'interno della classe xbrowse.prg ma non riesco ad uscirne.

Allego un esempio minimale

Grazie
Romeo

****************************
*
* testxbr.prg
*
#include "FiveWin.Ch"
#include "XBrowse.Ch"
*
function main()

local aDbf,oWnd, oBrw, oCol, oBrush, cAlias := cGetNewAlias( "CUST" )

aDbf := {}
AADD(aDbf,{ "NOME", "C", 25, 0 })
AADD(aDbf,{ "SALARIO1", "N", 9,0})
AADD(aDbf,{ "SALARIO2", "N", 9,2})
DBCREATE("CUSTO", aDbf)
USE CUSTO NEW ALIAS (cAlias)
APPE BLANK
REPLACE nome with "Rossi Mario",salario1 with 1234,salario2 with 1234.56

DEFINE dialog ownd TITLE "Test" FROM 0,0 TO 24,80

@ 0,0 XBROWSE oBrw OF ownd ALIAS cAlias ;
SIZE 200,100 ;
FOOTERS FASTEDIT LINES CELL

oBrw:bClrRowFocus := oBrw:bClrSelFocus


oBrw:CreateFromCode()
oWnd:oClient := oBrw


@9 ,1 button "To Excel" ACTION oBrw:ToExcel() of ownd

ACTIVATE dialog oWnd ON INIT oBrw:SetFocus() CENTERED

return nil
*
*** fine esempio
*
Grazie a Tutti

Re: xbrowse to excel

PostPosted: Mon Dec 29, 2014 11:16 am
by Patrizio
Prova a eseguire FWNumFormat( 'E', .t. ) all'inizio del programma, dovrebbe cambiare la formattazione standard usata anche per Excel.

Re: xbrowse to excel

PostPosted: Tue Dec 30, 2014 10:34 am
by Romeo
Grazie,
ho provato ma a funzione: FWNumFormat( 'E', .t. ) non e' riconosciuta e comunque ho provato a manomettere la classe xbrowse.prg, senza risultato !!

Peccato !
Romeo

Re: xbrowse to excel

PostPosted: Tue Dec 30, 2014 8:32 pm
by stefano
Ciao
così funziona:

@130,5 xBROWSE oLBX1 OF oDlg1 SIZE 390,170 ON DBLCLICK (varturno());
UPDATE pixel FONT fntArial NOBORDER

----

ADD COLUMN TO oLBX1 DATA gio2n ;
HEADER "Lu." SIZE 40 PICTURE "@E 9.99"

---
oLBX1:lExcelCellWise := .t.
olbx1:CreateFromCode()

saluti
Stefano

Re: xbrowse to excel

PostPosted: Mon Jan 12, 2015 11:34 am
by Romeo
Grazie, ma non mi funziona lo stesso.

Mi da l'errore e dice che:
oLBX1:lExcelCellWise .... non lo trova

Io ho la versione di FWH 8.10, forse e' un po vecchia ?

Help

Re: xbrowse to excel

PostPosted: Mon Jan 12, 2015 6:00 pm
by stefano
FW e Xbrowse sono cambiati parecchio dal 2010 ad oggi, ci sono parecchie novità .

Io ho approfittato dell'offerta (agg. 150,00 di alcuni mesi fa) prova a chiedere ad Antonio ...

Ciao
Stefano

Re: xbrowse to excel

PostPosted: Wed Jan 21, 2015 12:52 pm
by Silvio.Falconi
IN XBROWSE C'è UN ERRORE CHE ANCORA NON è STATO CORRETTO


IO USO QUESTA FUNZIONE HA BISOGNO DELLA CLASSE FILEXLS

Code: Select all  Expand view

#include "FiveWin.ch"
#include "FileXLS.ch"

function ExportXLS( oBrw )
  Local oXLS, nCol, nFormat, nFormat2, nFont, nLen, nCol, nFila, x, cText

   XLS oXLS FILE ".\file.xls" AUTOEXEC
       DEFINE XLS FORMAT nFormat PICTURE '#,##0.00'
       DEFINE XLS FORMAT nFormat2 PICTURE '#0'
       DEFINE XLS FONT nFont1 NAME "Arial" HEIGHT 16 BOLD

       @ 1,1 XLS SAY "MI XLS BROWSE" FONT nfont1 OF oXls  
       @ 1,8 XLS SAY "Fecha:" + DTOC( Date() ) OF oXls  

       // CABECERAS
       nLen  := len( oBrw:aCols )
       nCol  := 1
       nFila := 3
       for x := 1 to nLen
           if !oBrw:aCols[x]:lHide  // Si la columna no es oculta
              cValor := oBrw:aCols[x]:cHeader
              XLS COL nCol WIDTH oBrw:aCols[x]:nDataLen OF oXLS
              @ nFila,nCol XLS SAY cvalor BORDER OF oXls  
              nCol++  // Las columnas solo las que estan visibles
           endif
       next

       nCol  := 1
       nFila++   // Una fila despues del Header

        // DATOS
        DbSelectArea( oDbf:cAlias )
        oDbf:GoTop()
        while !oDbf:Eof()
              for x := 1 to nLen
                  if !oBrw:aCols[x]:lHide  // Si la columna no es oculta
                      cText := oBrw:aCols[x]:Value()
                      if Valtype( cText ) = "N" // Si es numeric
                        if oBrw:aCols[x]:nDataDec = 0
                           @ nFila, nCol XLS SAY cText FORMAT nFormat2 OF oXls
                        else
                           @ nFila, nCol XLS SAY cText FORMAT nFormat OF oXls
                        endif
                     /* else
                         @ nFila, nCol XLS SAY OemToAnsi( cText )  OF oXls*/


elseif Valtype( cText ) == "U"
@ nFila, nCol XLS SAY oBrw:aCols[x]:Cargo OF oXls
                      endif
                      nCol++  // Las columnas solo las que estan visibles
                  endif
              next
             nFila++
             nCol := 1
             oDbf:Skip()
        end While

   ENDXLS oXLS