FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index All products support xbrowse to excel
Posts: 340
Joined: Thu Jan 25, 2007 03:53 PM
xbrowse to excel
Posted: Tue Dec 09, 2014 11:46 AM

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

Posts: 90
Joined: Wed Nov 07, 2007 08:56 AM
Re: xbrowse to excel
Posted: Mon Dec 29, 2014 11:16 AM

Prova a eseguire FWNumFormat( 'E', .t. ) all'inizio del programma, dovrebbe cambiare la formattazione standard usata anche per Excel.

Posts: 340
Joined: Thu Jan 25, 2007 03:53 PM
Re: xbrowse to excel
Posted: Tue Dec 30, 2014 10:34 AM

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

Posts: 80
Joined: Tue Mar 25, 2008 09:03 PM
Re: xbrowse to excel
Posted: Tue Dec 30, 2014 08:32 PM

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

FWH 14.11 + xHarbour + bcc582
Posts: 340
Joined: Thu Jan 25, 2007 03:53 PM
Re: xbrowse to excel
Posted: Mon Jan 12, 2015 11:34 AM

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

Posts: 80
Joined: Tue Mar 25, 2008 09:03 PM
Re: xbrowse to excel
Posted: Mon Jan 12, 2015 06:00 PM

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

FWH 14.11 + xHarbour + bcc582
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: xbrowse to excel
Posted: Wed Jan 21, 2015 12:52 PM
IN XBROWSE C'è UN ERRORE CHE ANCORA NON è STATO CORRETTO


IO USO QUESTA FUNZIONE HA BISOGNO DELLA CLASSE FILEXLS

Code (fw): Select all Collapse
#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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion