FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Pregunta sobre FW_DbftoEXCEL
Posts: 328
Joined: Fri May 19, 2006 04:08 PM
Pregunta sobre FW_DbftoEXCEL
Posted: Tue Apr 04, 2023 08: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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Pregunta sobre FW_DbftoEXCEL
Posted: Wed Apr 05, 2023 12:38 AM
Syntax:
Code (fw): Select all Collapse
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 (fw): Select all Collapse
FW_DbfToExcel( nil, nil, nil, nil, nil, nil, "c:\folder\mytest.xlsx" )
OR

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



G. N. Rao.

Hyderabad, India
Posts: 328
Joined: Fri May 19, 2006 04:08 PM
Re: Pregunta sobre FW_DbftoEXCEL
Posted: Wed Apr 05, 2023 12:56 AM
nageswaragunupudi wrote:Syntax:
Code (fw): Select all Collapse
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 (fw): Select all Collapse
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
Posts: 328
Joined: Fri May 19, 2006 04:08 PM
Re: Pregunta sobre FW_DbftoEXCEL
Posted: Wed Apr 05, 2023 01: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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Pregunta sobre FW_DbftoEXCEL
Posted: Sat Apr 08, 2023 02: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 (fw): Select all Collapse
return nil
Change this line as:
Code (fw): Select all Collapse
return oSheet
You keep using the new function like this:
Code (fw): Select all Collapse
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
Posts: 328
Joined: Fri May 19, 2006 04:08 PM
Re: Pregunta sobre FW_DbftoEXCEL
Posted: Sat Apr 08, 2023 08: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
Posts: 328
Joined: Fri May 19, 2006 04:08 PM
Re: Pregunta sobre FW_DbftoEXCEL
Posted: Sat Apr 08, 2023 08: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 (fw): Select all Collapse
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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Pregunta sobre FW_DbftoEXCEL
Posted: Sun Apr 09, 2023 02:09 AM
Code (fw): Select all Collapse
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
Posts: 328
Joined: Fri May 19, 2006 04:08 PM
Re: Pregunta sobre FW_DbftoEXCEL
Posted: Sun Apr 09, 2023 05: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

Continue the discussion