Pregunta sobre FW_DbftoEXCEL

Pregunta sobre FW_DbftoEXCEL

Postby El Loco » Tue Apr 04, 2023 8:11 pm

Buenas Buenas gente.
Utilizo la funcion FW_DBFTOEXCEL() y todo va bien me convierte cualquier dbf en la planilla :D
...ahora la pregunta como hago para salvar la planilla excel?
Desde ya muchisimas gracias
Saludos


FWH 32/64 14.04 - PellesC
FWH 32/64 14.04
Harbour 3.2.0 (r1306211258)
PellesC
El Loco
 
Posts: 328
Joined: Fri May 19, 2006 4:08 pm
Location: Buenos Aires - Argentina

Re: Pregunta sobre FW_DbftoEXCEL

Postby nageswaragunupudi » Wed Apr 05, 2023 12:38 am

Syntax:
Code: Select all  Expand view
FW_DbfToExcel( [cFieldList], [bFor], [bWhile], [nNext], [nRec], [lRest], [cSaveTo], [lShow] ) --> oSheet


1. Specify the name of the file (with full path ) to be saved as the 7th parameter.
Example:
Code: Select all  Expand view
FW_DbfToExcel( nil, nil, nil, nil, nil, nil, "c:\folder\mytest.xlsx" )


OR

2.
Code: Select all  Expand view
oSheet := FW_DbfToExcel()
ExcelBookSaveAs( oSheet:Parent, cFileName )
Regards

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

Re: Pregunta sobre FW_DbftoEXCEL

Postby El Loco » Wed Apr 05, 2023 12:56 am

nageswaragunupudi wrote:Syntax:
Code: Select all  Expand view
FW_DbfToExcel( [cFieldList], [bFor], [bWhile], [nNext], [nRec], [lRest], [cSaveTo], [lShow] )


Specify the name of the file (with full path ) to be saved as the 7th parameter.

Example:
Code: Select all  Expand view
FW_DbfToExcel( nil, nil, nil, nil, nil, nil, "c:\folder\mytest.xlsx" )

Gracias RAO...ahora llego a casa y lo pruebo.
Abrazo enorme
Miguel
FWH 32/64 14.04
Harbour 3.2.0 (r1306211258)
PellesC
El Loco
 
Posts: 328
Joined: Fri May 19, 2006 4:08 pm
Location: Buenos Aires - Argentina

Re: Pregunta sobre FW_DbftoEXCEL

Postby El Loco » Wed Apr 05, 2023 1:08 am

Lamentablemente mi version debe ser muy vieja porque los dos ultimos paramentros ( [cSaveTo], [lShow ]) no los contempla
La que tengo llega hasta aqui FW_DbfToExcel( [cFieldList], [bFor], [bWhile], [nNext], [nRec], [lRest] )
Igualmente gracias
Abrazo
FWH 32/64 14.04
Harbour 3.2.0 (r1306211258)
PellesC
El Loco
 
Posts: 328
Joined: Fri May 19, 2006 4:08 pm
Location: Buenos Aires - Argentina

Re: Pregunta sobre FW_DbftoEXCEL

Postby nageswaragunupudi » Sat Apr 08, 2023 2:43 am

Checked version FWH 1404.
This function is available in \source\classes\database.prg

Please copy this entire function into your own application with a different name, for example, MY_DBFTOEXCEL(...).

The last line of this function is:
Code: Select all  Expand view
return nil

Change this line as:
Code: Select all  Expand view
return oSheet


You keep using the new function like this:
Code: Select all  Expand view

oSheet := MY_DBFTOEXCEL(...)
// if you want to save:
oSheet:Parent:SaveAs( cFile )
 

Make sure the file name is always with full path and exension "xlsx"
Regards

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

Re: Pregunta sobre FW_DbftoEXCEL

Postby El Loco » Sat Apr 08, 2023 8:04 pm

Perdon RAO recien veo tu post. En un rato lo pruebo.
Desde ya muchisimas gracias
Abrazo
FWH 32/64 14.04
Harbour 3.2.0 (r1306211258)
PellesC
El Loco
 
Posts: 328
Joined: Fri May 19, 2006 4:08 pm
Location: Buenos Aires - Argentina

Re: Pregunta sobre FW_DbftoEXCEL

Postby El Loco » Sat Apr 08, 2023 8:11 pm

RAO...abusando de tu generosidad como puedo agregarle a una funcion tuya que ya hace tiempo posteaste de pasar un array a excel
poder agregar los titulos
Code: Select all  Expand view
function ArrayToExcel2( aData )

   local oExcel, oBook, oSheet
   local cText, oClp, nCols := 0

   if ( oExcel := ExcelObj() ) == nil
      ? "Excel not instqalled"
   else
      oBook    := oExcel:WorkBooks:Add()
      oSheet   := oBook:ActiveSheet
      oExcel:ScreenUpdating := .f.

      aData    := AClone( aData )
      AEval( aData, { |a| nCols := Max( nCols, Len( a ) ) } )
      AEval( aData, { |a,i| aData[ i ] := FW_ArrayAsList( a, Chr( 9 ) ) } )
      cText    := FW_ArrayAsList( aData, CRLF )

      oClp     := TClipboard():New()
      oClp:SetText( cText )
      oSheet:Cells( 1, 1 ):Select()
      oSheet:Paste()
      oClp:Clear()
      oClp:End()

      oSheet:Range( oSheet:Columns( 1 ), oSheet:Columns( nCols ) ):AutoFit()

      oExcel:ScreenUpdating := .t.
      oExcel:visible := .t.
   endif

return nil


hace dos d'ias que intento y no pie con bola :oops:
Abrazo
FWH 32/64 14.04
Harbour 3.2.0 (r1306211258)
PellesC
El Loco
 
Posts: 328
Joined: Fri May 19, 2006 4:08 pm
Location: Buenos Aires - Argentina

Re: Pregunta sobre FW_DbftoEXCEL

Postby nageswaragunupudi » Sun Apr 09, 2023 2:09 am

Code: Select all  Expand view
function ArrayToExcel2( aData, aHead )

   local oExcel, oBook, oSheet
   local cText, oClp, nCols := 0

   if ( oExcel := ExcelObj() ) == nil
      ? "Excel not instqalled"
   else
      oBook    := oExcel:WorkBooks:Add()
      oSheet   := oBook:ActiveSheet
      oExcel:ScreenUpdating := .f.

      aData    := AClone( aData )
      if !Empty( aHead )
         HB_AIns( aData, 1, aHead, .t. ) // for xHarbour AINS(...)
      endif
     
      AEval( aData, { |a| nCols := Max( nCols, Len( a ) ) } )
      AEval( aData, { |a,i| aData[ i ] := FW_ArrayAsList( a, Chr( 9 ) ) } )
      cText    := FW_ArrayAsList( aData, CRLF )

      oClp     := TClipboard():New()
      oClp:SetText( cText )
      oSheet:Cells( 1, 1 ):Select()
      oSheet:Paste()
      oClp:Clear()
      oClp:End()

      oSheet:Range( oSheet:Columns( 1 ), oSheet:Columns( nCols ) ):AutoFit()

      if !Empty( aHead )
         oSheet:Rows( 1 ):Font:Bold   := .t.
      endif
     
      oExcel:ScreenUpdating := .t.
      oExcel:visible := .t.
   endif

return nil
 
Regards

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

Re: Pregunta sobre FW_DbftoEXCEL

Postby El Loco » Sun Apr 09, 2023 5:46 pm

Gracias RAO. Excelente las dos ayudas tuyas funcionan de maravillas
Con FW_DbftoEXCEL costo un poco la implementacion pero al fin arranco :D
Con ArrayToExcel2 funciono de primera Excelente excelente RAO Gracias infinitas
Ahora voy a intentar agregarla la opcion de salvar en disco la planilla....espero que me salga.
Tengo primero ver porque de repente me desaparecen los controles en un folder cuando venia funcionando perfecto.
Solo lo que hice es pasarlo de 32 a 64bits, creo que lo que necesito urgente es actualizar el FiveWIn. Espero que pronto pueda hacerlo.
Nuevamente muchisimas grascia RAO...sos realmente un maestro.
Abrazo eterno.
FWH 32/64 14.04
Harbour 3.2.0 (r1306211258)
PellesC
El Loco
 
Posts: 328
Joined: Fri May 19, 2006 4:08 pm
Location: Buenos Aires - Argentina


Return to FiveWin para Harbour/xHarbour

Who is online

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