eror export datos condicionados a Excel oBrw:ToExcel() SOLVE

eror export datos condicionados a Excel oBrw:ToExcel() SOLVE

Postby FranciscoA » Fri Jul 24, 2020 5:25 pm

Hola amigos.
¿Pueden indicarme dónde está el error en el siguiente codigo?

La falla es que únicamente exporta datos para la columna 1 (state), dejando las demás en blanco, en el fichero Excel.

Code: Select all  Expand view  RUN
#include "fivewin.ch"
#include "xBrowse.ch"

Function Main()
local oDlg, oBrw, cAlias, oFont
local oState, cState

   dbUseArea(.t.,,"Customer","CUST",.f.)
   dbSelectArea("CUST")
   index on field->State To cu temporary
   cAlias := Alias()

   (cAlias)->( OrdSetFocus("cu") )

   cState := space(len(Cust->state))

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14

   DEFINE DIALOG oDlg SIZE 800,500 PIXEL TRUEPIXEL FONT oFont;
      TITLE "Exportar Brw-Xls datos condicionados"

   @ 20, 20 SAY "State" SIZE 100,20 PIXEL OF oDlg

   @ 20,120 GET oState VAR cState SIZE 100,20 PIXEL OF oDlg PICTURE "@!"

   @ 50,120 BUTTON "Exportar" SIZE 100,20 PIXEL OF oDlg  ;
            ACTION Exporte(oBrw,cState) WHEN !empty(cState)

   @ 20,250 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE "CUST" ;
      COLUMNS 'State','First', 'City' ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      oBrw:CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

   RELEASE FONT oFont

   (cAlias)->(dbCloseArea())
return nil
//-----------------------------------------//
Function Exporte(oBrw,cState)
local aRecNo := {}
local bCondi := { || (oBrw:cAlias)->STATE == cState }

   //Preparar array de registros a exportar, según condición.
   (oBrw:cAlias)->( DBEVAL( { || AAdd( aRecNo, RECNO() ) }, bCondi ) )

   (oBrw:cAlias)->( DBseek(cState,.t.) )
   oBrw:Refresh()

   //Asignar el array a oBrw:aSelected, exportar datos, y limpiar oBrw:aSelected
   oBrw:aSelected := aRecNo
   oBrw:ToExcel()    // <--- Por qué solo exporta valores para la columna 1 (State)?
   oBrw:aSelected := {}

Return nil
 


Gracias.
Last edited by FranciscoA on Thu Jul 30, 2020 4:49 pm, edited 1 time 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: Error export datos condicionados a Excel oBrw:ToExcel()

Postby nageswaragunupudi » Fri Jul 24, 2020 11:09 pm

Working correctly for me here:

Image

May we know which version of FWH you tested?
Regards

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

Re: Error export datos condicionados a Excel oBrw:ToExcel()

Postby FranciscoA » Sat Jul 25, 2020 1:21 am

Rao, thanks for your reply.
Fwh1709.
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: Error export datos condicionados a Excel oBrw:ToExcel()

Postby nageswaragunupudi » Thu Jul 30, 2020 3:07 am

For FWH 1709, please make this small modification in the function Exporte(...)

Code: Select all  Expand view  RUN
Function Exporte(oBrw,cState)
local aRecNo := {}
local bCondi := { || (oBrw:cAlias)->STATE == cState }
local nStyle := oBrw:nMarqueeStyle

   //Preparar array de registros a exportar, según condición.
   (oBrw:cAlias)->( DBEVAL( { || AAdd( aRecNo, RECNO() ) }, bCondi ) )

   (oBrw:cAlias)->( DBseek(cState,.t.) )
   oBrw:Refresh()

   //Asignar el array a oBrw:aSelected, exportar datos, y limpiar oBrw:aSelected
   oBrw:aSelected := aRecNo
   oBrw:nMarqueeStyle := 4
   oBrw:ToExcel()    // <--- Por qué solo exporta valores para la columna 1 (State)?
   oBrw:nMarqueeStyle := nStyle
   oBrw:aSelected := {}

Return nil
 


Please let us know if this works
Regards

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

Re: Error export datos condicionados a Excel oBrw:ToExcel()

Postby FranciscoA » Thu Jul 30, 2020 4:39 pm

nageswaragunupudi wrote:For FWH 1709, please make this small modification in the function Exporte(...)

Code: Select all  Expand view  RUN
Function Exporte(oBrw,cState)
local aRecNo := {}
local bCondi := { || (oBrw:cAlias)->STATE == cState }
local nStyle := oBrw:nMarqueeStyle

   //Preparar array de registros a exportar, según condición.
   (oBrw:cAlias)->( DBEVAL( { || AAdd( aRecNo, RECNO() ) }, bCondi ) )

   (oBrw:cAlias)->( DBseek(cState,.t.) )
   oBrw:Refresh()

   //Asignar el array a oBrw:aSelected, exportar datos, y limpiar oBrw:aSelected
   oBrw:aSelected := aRecNo
   oBrw:nMarqueeStyle := 4
   oBrw:ToExcel()  
   oBrw:nMarqueeStyle := nStyle
   oBrw:aSelected := {}

Return nil
 


Please let us know if this works


Yes. Now it is working fine.
Thanks.
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 para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 76 guests