Mr. Rao, From PREVIEW To Excel (SOLVED)

Mr. Rao, From PREVIEW To Excel (SOLVED)

Postby Armando » Wed Mar 03, 2021 7:21 pm

Mr. Rao:

I have the following code.

Code: Select all  Expand view  RUN

    REPORT oReporte CAPTION cTitulo PREVIEW ;
        HEADER ALLTRIM(oApp:cRazonSocial),;
        "",;
        cTitulo CENTER;
        TITLE "Fecha: "+Date2Txt(DATE()),;
        "Hoja No:"+STR(oReporte:nPage,3);
        FONT oFont1,oFont2,oFont3;
        PEN oPen1,oPen2

        COLUMN TITLE "Folio"            DATA "" SIZE  4 RIGHT
        COLUMN TITLE "Concepto"     DATA "" SIZE 35 LEFT
        COLUMN TITLE "Referencia"   DATA "" SIZE 12 LEFT
        COLUMN TITLE "Importe"      DATA "" SIZE 11 RIGHT
        COLUMN TITLE "Prestamos"    DATA "" SIZE 11 RIGHT
    END REPORT

    IF oReporte:lCreated
        oReporte:SetTxtColor(CLR_BLACK,1)
        oReporte:SetTxtColor(CLR_HRED,2)
        oReporte:SetTxtColor(CLR_HRED,3)
        oReporte:SetPenColor(CLR_HBLUE)
        oReporte:SetShdColor(CLR_YELLOW)
        oReporte:oHeader:aFont[1] := {||3}

        oReporte:oTitle:aPad[1] := RPT_LEFT
        oReporte:oTitle:aPad[2] := RPT_RIGHT

      oReporte:bInit := {|| oRsGas:MoveFirst() }

        oReporte:nTopMargin     := 300
        oReporte:nDnMargin      := 300

       oReporte:bSkip := { || (nLinea++, oRsGas:MoveNext())}

    ENDIF

   ACTIVATE REPORT oReporte ;
        ON STARTPAGE Alinea(oReporte,1,2);
        ON CHANGE PonDet(oReporte);
        ON END (TotFin(oReporte,oBrw),oRsGas:BookMark := nBookMark);
      WHILE nLinea <= nHasta

    oRsGas:SORT := "GAS_GAS ASC"

    oBrw:Refresh()

    oFont1:Release()
    oFont2:Release()
    oFont3:Release()
    oPen1:Release()
    oPen2:Release()
RETURN(.T.)
 


Image

But when exporting it to Excel shows it incomplete, could you help me?, what am I omitting?

Image

With best regards
Last edited by Armando on Sat Mar 06, 2021 5:01 pm, edited 1 time in total.
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3229
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Mr. Rao, From PREVIEW To Excel

Postby karinha » Wed Mar 03, 2021 9:11 pm

Que belo REPORT Armando, podrias poner el código completo para el amigo aqui?

Muchas gracias.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7832
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Mr. Rao, From PREVIEW To Excel

Postby Armando » Wed Mar 03, 2021 9:45 pm

Karinha:

El código está completo. Si te reclama algo me avisas.

Saludos
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3229
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Mr. Rao, From PREVIEW To Excel

Postby nageswaragunupudi » Sat Mar 06, 2021 1:59 pm

This is a working sample:
Code: Select all  Expand view  RUN
function AdoReport()

   local oCn, oRs, oRep, oFont

   oCn   := FW_OpenAdoConnection( "xbrtest.mdb" )
   oRs   := FW_OpenRecordSet( oCn, "select * from customer where id <= 5" )

   xbrowser oRs
   oRs:MoveFirst()

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-10
   REPORT oRep PREVIEW FONT oFont ;
      HEADER "CUSTOMER" CENTER ;
      TITLE "Date : " + FW_TRANSFORM( DATE(), "dd-mmmm-yyyy" ) LEFT

   COLUMN TITLE "FIRST"  DATA oRs:Fields( "FIRST"  ):Value SIZE 20
   COLUMN TITLE "CITY"   DATA oRs:Fields( "CITY"   ):Value SIZE 20
   COLUMN TITLE "SALARY" DATA oRs:Fields( "SALARY" ):Value SIZE 20 PICTURE "9,999,999.99" TOTAL RIGHT

   ENDREPORT

   oRep:bInit := { || oRs:MoveFirst() }
   oRep:bSkip := { || oRs:MoveNext() }

   ACTIVATE REPORT oRep WHILE !oRs:Eof()

   oRs:Close()
   oCn:Close()

return nil


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Mr. Rao, From PREVIEW To Excel

Postby Armando » Sat Mar 06, 2021 5:01 pm

Mr. Rao:

Your sample Works fine but We have a difference between codes, as you can see

My sorce code
Code: Select all  Expand view  RUN

        COLUMN TITLE "Folio"            DATA ""  SIZE  4 RIGHT   <=== Here is a first one difference
        COLUMN TITLE "Concepto"     DATA "" SIZE 35 LEFT
        COLUMN TITLE "Referencia"   DATA "" SIZE 12 LEFT
        COLUMN TITLE "Importe"      DATA "" SIZE 11 RIGHT
        COLUMN TITLE "Prestamos"    DATA "" SIZE 11 RIGHT




   ACTIVATE REPORT oReporte ;
        ON STARTPAGE Alinea(oReporte,1,2);
        [b]ON CHANGE PonDet(oReporte);[/b]   <======= Here is a second one difference
        ON END (TotFin(oReporte,oBrw),oRsGas:BookMark := nBookMark);
      WHILE ! oRsGas:EOF()
….


STATIC FUNCTION PonDet(oReporte)
    IF cUser <> oRsGas:Fields("GAS_USU"):Value
        IF cUser <> NIL
            TotUser(oReporte,(.F.))
        ENDIF
        oReporte:SAY(1,"Usuario: " + oRsGas:Fields("GAS_USU"):Value,2,RPT_LEFT)
        cUser := oRsGas:Fields("GAS_USU"):Value
        oReporte:EndLine()
    ENDIF

    oReporte:SAY(01,TRANSFORM(oRsGas:Fields("GAS_GAS"):Value,"@Z 9999999"),,RPT_RIGHT)
    oReporte:SAY(02,oRsGas:Fields("GAS_CPT"):Value,,RPT_LEFT)
    oReporte:SAY(03,oRsGas:Fields("GAS_REF"):Value,,RPT_LEFT)
    oReporte:SAY(04,IIF(oRsGas:Fields("GAS_CAN"):Value,"CANCELADO",TRANSFORM(oRsGas:Fields("GAS_IMP"):Value,"@Z 999,999,999.99")),,RPT_RIGHT)
    IF "PRESTAMO" $ oRsGas:Fields("GAS_CPT"):Value
        oReporte:SAY(05,IIF(oRsGas:Fields("GAS_CAN"):Value,"CANCELADO",TRANSFORM(oRsGas:Fields("GAS_IMP"):Value,"@Z 999,999,999.99")),,RPT_RIGHT)
        IF ! oRsGas:Fields("GAS_CAN"):Value
            nTotPus += oRsGas:Fields("GAS_IMP"):Value
            nTotPfi += oRsGas:Fields("GAS_IMP"):Value
        ENDIF
    ENDIF

    IF ! oRsGas:Fields("GAS_CAN"):Value
        nTotUsu += oRsGas:Fields("GAS_IMP"):Value
    ENDIF
RETURN(.T.)
 


With my code does not work

Best Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3229
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Mr. Rao, From PREVIEW To Excel (SOLVED)

Postby FranciscoA » Sun Mar 07, 2021 12:19 am

Armando wrote:Mr. Rao:

Your sample Works fine but We have a difference between codes, as you can see

My sorce code
Code: Select all  Expand view  RUN

        COLUMN TITLE "Folio"            DATA ""  SIZE  4 RIGHT   <=== Here is a first one difference
        COLUMN TITLE "Concepto"     DATA "" SIZE 35 LEFT
        COLUMN TITLE "Referencia"   DATA "" SIZE 12 LEFT
        COLUMN TITLE "Importe"      DATA "" SIZE 11 RIGHT
        COLUMN TITLE "Prestamos"    DATA "" SIZE 11 RIGHT




   ACTIVATE REPORT oReporte ;
        ON STARTPAGE Alinea(oReporte,1,2);
        [b]ON CHANGE PonDet(oReporte);[/b]   <======= Here is a second one difference
        ON END (TotFin(oReporte,oBrw),oRsGas:BookMark := nBookMark);
      WHILE ! oRsGas:EOF()
….


STATIC FUNCTION PonDet(oReporte)
    IF cUser <> oRsGas:Fields("GAS_USU"):Value
        IF cUser <> NIL
            TotUser(oReporte,(.F.))
        ENDIF
        oReporte:SAY(1,"Usuario: " + oRsGas:Fields("GAS_USU"):Value,2,RPT_LEFT)
        cUser := oRsGas:Fields("GAS_USU"):Value
        oReporte:EndLine()
    ENDIF

    oReporte:SAY(01,TRANSFORM(oRsGas:Fields("GAS_GAS"):Value,"@Z 9999999"),,RPT_RIGHT)
    oReporte:SAY(02,oRsGas:Fields("GAS_CPT"):Value,,RPT_LEFT)
    oReporte:SAY(03,oRsGas:Fields("GAS_REF"):Value,,RPT_LEFT)
    oReporte:SAY(04,IIF(oRsGas:Fields("GAS_CAN"):Value,"CANCELADO",TRANSFORM(oRsGas:Fields("GAS_IMP"):Value,"@Z 999,999,999.99")),,RPT_RIGHT)
    IF "PRESTAMO" $ oRsGas:Fields("GAS_CPT"):Value
        oReporte:SAY(05,IIF(oRsGas:Fields("GAS_CAN"):Value,"CANCELADO",TRANSFORM(oRsGas:Fields("GAS_IMP"):Value,"@Z 999,999,999.99")),,RPT_RIGHT)
        IF ! oRsGas:Fields("GAS_CAN"):Value
            nTotPus += oRsGas:Fields("GAS_IMP"):Value
            nTotPfi += oRsGas:Fields("GAS_IMP"):Value
        ENDIF
    ENDIF

    IF ! oRsGas:Fields("GAS_CAN"):Value
        nTotUsu += oRsGas:Fields("GAS_IMP"):Value
    ENDIF
RETURN(.T.)
 


With my code does not work

Best Regards


With my code does not work


+1
He probado la combinación de tu códicogo con el del siguiente link, con los mismos resultados.

Aquí también solicitan lo mismo:
viewtopic.php?f=6&t=40056&sid=c4f53f57e0f1f2f8b95c99c2b8a24eac#p239044

Yo siempre lo he hecho de la manera en que lo presenta Rao, pero es interesante conocer por qué no exporta los datos a Excel si se usa una función de usuario.
Saludos.
Last edited by FranciscoA on Sun Mar 07, 2021 12:42 am, edited 2 times in total.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2159
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Mr. Rao, From PREVIEW To Excel (SOLVED)

Postby FranciscoA » Sun Mar 07, 2021 12:34 am

Este es el codigo que estoy probando:

Code: Select all  Expand view  RUN
//------------------------------------------//
Function LstEstdCta(oQry, dFechaI,dFechaF,cCta,cNomCta,nRecno,lCtaAcreed)
local oReport, oPrn, oFont1, oFont2, oFont3, oFont4, oPen1, oPen2, nCancelar := 0
local cTitulo := "DETALLE DE LA CTA: "+ alltrim(cCta)+"  "+alltrim(cNomCta)
local  nDebe := 0, nHaber := 0
local cFecha

    cFecha := Fechador(dFechaI,dFechaF)

    nCancelar := PrinterSetup(oPrn)
    if nCancelar = 0
       return nil
    endif

    DEFINE FONT oFont1 NAME "ARIAL" SIZE 0,-08
    DEFINE FONT oFont2 NAME "ARIAL" SIZE 0,-09 BOLD
    DEFINE FONT oFont3 NAME "ARIAL" SIZE 0,-10 BOLD ITALIC
    DEFINE FONT oFont4 NAME "ARIAL" SIZE 0,-10 BOLD ITALIC
    DEFINE PEN oPen1 WIDTH 1
    DEFINE PEN oPen2 WIDTH 1

    REPORT oReport CAPTION cTitulo PREVIEW ;
        HEADER EMPRESA +"  "+ MEMBRE, "" ,;     //Se usa HEADER como TITLE
               cTitulo ,;
               cFecha CENTER ;
        TITLE  "Fecha: " + DToC(Date()) ,;      //Se usa TITLE como HEADER
               "Hoja No:"+STR(oReport:nPage,3) ;
        FONT   oFont1,oFont2,oFont3,oFont4 ;
        PEN    oPen1,oPen2

        COLUMN TITLE "Fecha"     DATA "" SIZE 10
        COLUMN TITLE "Dcto No."  DATA "" SIZE 10
        COLUMN TITLE "Concepto"  DATA "" SIZE 48
        COLUMN TITLE "Debitos"   DATA "" SIZE 12
        COLUMN TITLE "Creditos"  DATA "" SIZE 12
        COLUMN TITLE "Saldo"     DATA "" SIZE 12
    END REPORT

    IF oReport:lCreated
       oReport:SetTxtColor(CLR_BLACK,1)    
       oReport:SetTxtColor(CLR_HRED,2)
       oReport:SetTxtColor(CLR_HRED,3)
       oReport:SetTxtColor(CLR_GREEN,4)
       oReport:SetPenColor(CLR_HBLUE)
       oReport:SetShdColor(CLR_YELLOW)

       oReport:oHeader:aFont[1] := {|| 3 }  
       oReport:oHeader:aFont[3] := {|| 4 }  
       oReport:oHeader:aFont[4] := {|| 4 }  

       oReport:oTitle:aPad[1] := RPT_LEFT     //fecha
       oReport:oTitle:aPad[2] := RPT_RIGHT    //pag

       oReport:nTopMargin     := 300
       oReport:nDnMargin      := 300

       oReport:bInit := {|| oQry:GoTop() }
       oReport:bSkip := {|| oQry:Skip() }  

       oReport:bEndPage := {|| if(!oReport:lFinish, ( oReport:nRow += 32, oReport:TotalLine(oReport:nGroupLine, 1) ),) }

       AEval(oReport:aColumns,{|oCol| oCol:nAlignTitle := RPT_CENTER })
    ENDIF

    ACTIVATE REPORT oReport ;  
        ON CHANGE LnDatos(oReport, oQry, @nDebe ,@nHaber) ;
        ON END LnGranTot(oReport, nDebe, nHaber) ;
        WHILE !oQry:Eof()  

    RELEASE oFont1,oFont2,oFont3,oFont4,oPen1,oPen2

RETURN(.T.)

//------------------------------------------//
Function LnDatos(oReport, oQry, nDebe, nHaber)
   oReport:Say(  1, oQry:FECHEMIS, 1, 1 )
   oReport:Say(  2, oQry:NUMDOC, 1, 1 )
   oReport:Say(  3, Substr(oQry:CONCEPTO,1,48), 1, 1 )
   oReport:Say(  4, Transform( oQry:DEBE, "9,999,999,999.99" ), 1, 2 )
   oReport:Say(  5, Transform( oQry:HABER,"9,999,999,999.99" ), 1, 2 )
   oReport:Say(  6, Transform( oQry:SALDO,"9,999,999,999.99" ), 1, 2 )
   nDebe  += oQry:DEBE
   nHaber += oQry:HABER
Return nil
//------------------------------------------//
Function LnGranTot(oReport, nDebe, nHaber)
   oReport:NewLine()
   oReport:TotalLine(oReport:nGroupLine, 1)    //lin sencilla

   oReport:Say(  3, "Total Debitos y Creditos", 1, 2 )
   oReport:Say(  4, Transform( nDEBE, "9,999,999,999.99" ), 1, 2 )
   oReport:Say(  5, Transform( nHABER,"9,999,999,999.99" ), 1, 2 )

   oReport:NewLine()
   oReport:TotalLine(oReport:nTotalLine, 1)    //lin doble
Return nil


Saludos.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2159
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 33 guests