FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Exportar a Excel
Posts: 537
Joined: Mon Jan 16, 2006 03:42 PM
Exportar a Excel
Posted: Thu Mar 27, 2025 01:24 PM

Hola colegas

necesito de su ayuda, genero un informe por excel 2007 y funciona bien, luego en otro computador hay un excel plus 2019 y se cae, este es error

Error occurred at: 27-03-2025, 09:52:23

Error description: Error excel.application:WORKBOOKS:ADD:WORKSHEETS/3 DISP_E_MEMBERNOTFOUND: _NAME

Args:

 [   1] = C

Stack Calls

===========

Called from: => TOLEAUTO:_NAME( 0 )

Called from: C:\SYSTEMA\BUS\PRG\winges25.prg => EXPOR( 286 )

Called from: C:\SYSTEMA\BUS\PRG\winges25.prg => (b)EXPORTARTODOS( 193 )

Called from: C:\SYSTEMA\BUS\PRG\msgrun.prg => (b)MSGRUN( 39 )

Called from: .\source\classes\DIALOG.PRG => (b)TDIALOG:TDIALOG( 87 )

alguna ayuda

Saludos

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Exportar a Excel
Posted: Thu Mar 27, 2025 02:12 PM
Muestre:
   winges25.prg => EXPOR( 286 )
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 537
Joined: Mon Jan 16, 2006 03:42 PM
Re: Exportar a Excel
Posted: Thu Mar 27, 2025 02:42 PM

esa es la linea

oSheet:name:=AllTrim(cConvenio:HojaExcel) //286

saludos

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Exportar a Excel
Posted: Thu Mar 27, 2025 03:11 PM
jbrita wrote: esa es la linea

oSheet:name:=AllTrim(cConvenio:HojaExcel) //286


saludos
NAME Ó _NAME?

Mira se ayuda,

https://www.fivetechsoft.com/forums/viewtopic.php?t=32781

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1144
Joined: Mon Feb 05, 2007 07:15 PM
Re: Exportar a Excel
Posted: Thu Mar 27, 2025 04:50 PM

En las últimas versiones de fwh/EXCEL 2019 no funcionan algunas funciones de CREATEOBJECT( "Excel.Application" )

//::oSheet := ::oBook:Worksheets(1)

//nFormat := ::oBook:Get("FileFormat")

//::oBook:saveAS( cFileXls, nFormat )

//::oExcel:Quit()

y como dice el amigo @jbrita con versiones anteriores no hay problema

Saludos

Cesar Cortes Cruz

SysCtrl Software

Mexico



' Sin +- FWH es mejor "
Posts: 1144
Joined: Mon Feb 05, 2007 07:15 PM
Re: Exportar a Excel
Posted: Thu Mar 27, 2025 04:57 PM

en mi caso tuve que regresar a a versión HARBOUR/FWH23.07

SALUDOS !!!

Cesar Cortes Cruz

SysCtrl Software

Mexico



' Sin +- FWH es mejor "
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Exportar a Excel
Posted: Thu Mar 27, 2025 06:52 PM
Compile este ejemplo y vea si funciona bien con la versión Excel 2019.
// C:\FWH\SAMPLES\EXCELDBF.PRG

#include "FiveWin.ch"

FUNCTION Main()

   LOCAL Archivo1, Archivo2
   LOCAL _cExe := "Excel.exe", _nKill := 2, lOk

   lOk := EstaRodandoKillExe( _cExe, _nKill )

   IF( lOk )
      // NADA A FAZER
   ELSE // FORCA SE NAO FUNCIONAR

      WaitRun( "CMD /C TASKKILL.EXE /IM Excel.exe /F", 0 )

   ENDIF

   Archivo1 := "C:\TMP\CUSTOMER.DBF"

   XLS2DBF( Archivo1 )

RETURN NIL

FUNCTION XLS2DBF( cDbfName )

   // Purpose: convert an Excel spreadsheet to a dBase III+ table
   // but does not leave Excel open
   LOCAL oExcel
   LOCAL oWorkBook, oSheet, oError

   TRY
      oExcel := TOleAuto():New( "Excel.Application" )

   CATCH

      TRY
         oExcel := CreateObject( "Excel.Application" )

      CATCH oError

         Alert( "ERROR! Excel not avialable. [" + Ole2TxtError()+ "]" + oError:description )

         RETURN NIL
      END

   END

   oWorkbook = oExcel:WorkBooks:Open( cDbfName )

   oSheet = oExcel:ActiveSheet

   oSheet:SaveAs( "C:\TMP\CUSTOMER.CSV",  6 ) // Segundo parâmetro informa o tipo de saída
   oSheet:SaveAs( "C:\TMP\CUSTOMER.XLS", 56 ) // Segundo parâmetro informa o tipo de saída

   oWorkBook:Close( .F. )

   oExcel:Quit()

   oSheet    := NIL
   oWorkBook := NIL
   oExcel    := NIL

RETURN  NIL
/*
* Verificar se um Exe est  sendo executado e podendo at‚ derruba-lo
* Parametros: _cExe, _nKill
* Retorno: Retorno - .t. se estiver rodando
*
* Autor: toya
*/
// Is the executable running? - 27/03/2025 - Thanks: Alessandro/Toya.
FUNCTION EstaRodandoKillExe( _cExe, _nKill )

   LOCAL Retorno := .F.
   LOCAL oScriptObj
   LOCAL oWmiService
   LOCAL oListaProcess
   LOCAL oProcessos

   hb_default( @_nKill, 0 )

   oScriptObj    := CREATEOBJECT( "wbemScripting.SwbemLocator" )
   oWmiService   := oScriptObj:ConnectServer()
   oListaProcess := oWmiService:ExecQuery( "select * from Win32_Process where Name='" + _cExe + "'" )

   FOR EACH oProcessos in oListaProcess

      Retorno := .T.

      IF _nKill == 2

         oProcessos:Terminate() // mata o _cEXE

      ENDIF

   NEXT

RETURN( Retorno )

FUNCTION hb_default( xVar, xValue ) // Only xHarbour

   IF ValType( xVar ) != ValType( xValue )

      xVar := xValue

   ENDIF

RETURN NIL

// FIN / END - kapiabafwh@gmail.com
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1144
Joined: Mon Feb 05, 2007 07:15 PM
Re: Exportar a Excel
Posted: Thu Mar 27, 2025 07:26 PM

Joao ,

ya no tengo la pc office 2019,

pero funciona en ms office 2021

a ver si @jbrita pude probar con ms office 2019

gracias !!

Cesar Cortes Cruz

SysCtrl Software

Mexico



' Sin +- FWH es mejor "
Posts: 298
Joined: Fri Oct 07, 2005 05:20 AM
Re: Exportar a Excel
Posted: Thu Mar 27, 2025 11:17 PM
Hace dos años realicé una modificación al fuente de la clase TExcel para utilizarla solamente con Harbour 3.0.0 ( Rev. 16951 ) y funciona sin problemas con la versión de Microsoft Office Profesional Plus 2019.
/*
 *  TExcelScript():New()
 */
METHOD New() CLASS TExcelScript

/*
  ::oExcel := TOleAuto():New("Excel.Application")
  ::aExcelCols := {}

  ::oClip:=TClipBoard():New()
  ::oClip:Clear()
*/
	IF ( ::oExcel := win_oleCreateObject( "Excel.Application" ) ) != NIL
		::lOk := .T.
	ELSE
		ALERT( "Error: MS Excel not available. [" + win_oleErrorText()+ "]" )
	ENDIF

RETURN( Self )
jbrita wrote: Hola colegas
necesito de su ayuda, genero un informe por excel 2007 y funciona bien, luego en otro computador hay un excel plus 2019 y se cae, este es error

Error occurred at: 27-03-2025, 09:52:23
Error description: Error excel.application:WORKBOOKS:ADD:WORKSHEETS/3 DISP_E_MEMBERNOTFOUND: _NAME
Args:
[ 1] = C

Stack Calls
===========
Called from: => TOLEAUTO:_NAME( 0 )
Called from: C:\SYSTEMA\BUS\PRG\winges25.prg => EXPOR( 286 )
Called from: C:\SYSTEMA\BUS\PRG\winges25.prg => (b)EXPORTARTODOS( 193 )
Called from: C:\SYSTEMA\BUS\PRG\msgrun.prg => (b)MSGRUN( 39 )
Called from: .\source\classes\DIALOG.PRG => (b)TDIALOG:TDIALOG( 87 )

alguna ayuda
Saludos
Vikthor
Posts: 298
Joined: Fri Oct 07, 2005 05:20 AM
Re: Exportar a Excel
Posted: Thu Mar 27, 2025 11:26 PM
El primer método devuelve un arreglo con el nombre de todas las hojas activas.
El segundo renombra una hoja.
/*
 *  TExcelScript():HowSheet()
*/

METHOD HowSheet() CLASS TExcelScript
	LOCAL nSheets := ::oExcel:Sheets:Count()
	LOCAL i
	::aSheets := {}
	FOR i := 1 TO nSheets
		 aadd( ::aSheets , ::oExcel:Sheets:Item( i ):Name )
	NEXT
RETURN ( Nil )

METHOD NameSheet(cSheet,cName)        INLINE ::oExcel:Sheets(cSheet):Name := cName
jbrita wrote: esa es la linea

oSheet:name:=AllTrim(cConvenio:HojaExcel) //286


saludos
Vikthor
Posts: 1144
Joined: Mon Feb 05, 2007 07:15 PM
Re: Exportar a Excel
Posted: Sat Mar 29, 2025 06:32 PM
Interesante Victor,
y don descargo la tExcel? :shock: :shock: :shock: :shock:
gracias !
Cesar Cortes Cruz

SysCtrl Software

Mexico



' Sin +- FWH es mejor "
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Exportar a Excel
Posted: Sun Mar 30, 2025 04:20 PM
sysctrl2 wrote: Interesante Victor,
y don descargo la tExcel? :shock: :shock: :shock: :shock:
gracias !
Mi querido amigo César, mira se és esta:

Download completo, aqui:

https://mega.nz/file/kA0jDY4L#vhdRY5LU8D_DxczE1f6lDnwQK4beYupyy85mTZdF_b0

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1144
Joined: Mon Feb 05, 2007 07:15 PM
Re: Exportar a Excel
Posted: Mon Mar 31, 2025 05:20 PM

Gracias Joao, que amable

vamos a probar.

Cesar Cortes Cruz

SysCtrl Software

Mexico



' Sin +- FWH es mejor "
Posts: 298
Joined: Fri Oct 07, 2005 05:20 AM
Re: Exportar a Excel
Posted: Tue Apr 01, 2025 12:42 AM
La última versión de la clase TExcelS la puedes descargar del siguiente enlace.

https://github.com/Vikthor-Thomas/Harbour/blob/main/TEXCELS.prg
sysctrl2 wrote: Interesante Victor,
y don descargo la tExcel? :shock: :shock: :shock: :shock:
gracias !
Vikthor
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Exportar a Excel
Posted: Tue Apr 01, 2025 01:49 PM
Vikthor wrote: La última versión de la clase TExcelS la puedes descargar del siguiente enlace.

https://github.com/Vikthor-Thomas/Harbour/blob/main/TEXCELS.prg
Interesante Victor,
y don descargo la tExcel? :shock: :shock: :shock: :shock:
gracias !
Buenos días Vikthor, ¿dónde puedo conseguir ejemplos sencillos para probar esta excelente clase que creaste?

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341