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

Post Reply
User avatar
FranciscoA
Posts: 1964
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

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

Post by FranciscoA »

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

#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.

Fwxh1204-MySql-TMySql
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

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

Post by nageswaragunupudi »

Working correctly for me here:

Image

May we know which version of FWH you tested?
Regards

G. N. Rao.
Hyderabad, India
User avatar
FranciscoA
Posts: 1964
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

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

Post by FranciscoA »

Rao, thanks for your reply.
Fwh1709.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh1204-MySql-TMySql
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

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

Post by nageswaragunupudi »

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

Code: Select all

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
FranciscoA
Posts: 1964
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

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

Post by FranciscoA »

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

Code: Select all

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.

Fwxh1204-MySql-TMySql
Post Reply