Exportar a Excel

Post Reply
jbrita
Posts: 509
Joined: Mon Jan 16, 2006 3:42 pm

Exportar a Excel

Post by jbrita »

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
User avatar
karinha
Posts: 7988
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 6 times
Contact:

Re: Exportar a Excel

Post by karinha »

Muestre:

Code: Select all | Expand

   winges25.prg => EXPOR( 286 )
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
jbrita
Posts: 509
Joined: Mon Jan 16, 2006 3:42 pm

Re: Exportar a Excel

Post by jbrita »

esa es la linea

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


saludos
User avatar
karinha
Posts: 7988
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 6 times
Contact:

Re: Exportar a Excel

Post by karinha »

jbrita wrote: Thu Mar 27, 2025 2:42 pm esa es la linea

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


saludos
NAME Ó _NAME?

Mira se ayuda,

https://www.fivetechsoft.com/forums/vie ... hp?t=32781

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
sysctrl2
Posts: 1073
Joined: Mon Feb 05, 2007 7:15 pm
Has thanked: 8 times
Been thanked: 3 times
Contact:

Re: Exportar a Excel

Post by sysctrl2 »

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 "
User avatar
sysctrl2
Posts: 1073
Joined: Mon Feb 05, 2007 7:15 pm
Has thanked: 8 times
Been thanked: 3 times
Contact:

Re: Exportar a Excel

Post by sysctrl2 »

en mi caso tuve que regresar a a versión HARBOUR/FWH23.07
SALUDOS !!!
Cesar Cortes Cruz
SysCtrl Software
Mexico

' Sin +- FWH es mejor "
User avatar
karinha
Posts: 7988
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 6 times
Contact:

Re: Exportar a Excel

Post by karinha »

Compile este ejemplo y vea si funciona bien con la versión Excel 2019.

Code: Select all | Expand

// 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
User avatar
sysctrl2
Posts: 1073
Joined: Mon Feb 05, 2007 7:15 pm
Has thanked: 8 times
Been thanked: 3 times
Contact:

Re: Exportar a Excel

Post by sysctrl2 »

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 "
User avatar
Vikthor
Posts: 286
Joined: Fri Oct 07, 2005 5:20 am
Location: México
Been thanked: 3 times

Re: Exportar a Excel

Post by Vikthor »

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.

Code: Select all | Expand


/*
 *  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: Thu Mar 27, 2025 1: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
Vikthor
User avatar
Vikthor
Posts: 286
Joined: Fri Oct 07, 2005 5:20 am
Location: México
Been thanked: 3 times

Re: Exportar a Excel

Post by Vikthor »

El primer método devuelve un arreglo con el nombre de todas las hojas activas.
El segundo renombra una hoja.

Code: Select all | Expand


/*
 *  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: Thu Mar 27, 2025 2:42 pm esa es la linea

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


saludos
Vikthor
User avatar
sysctrl2
Posts: 1073
Joined: Mon Feb 05, 2007 7:15 pm
Has thanked: 8 times
Been thanked: 3 times
Contact:

Re: Exportar a Excel

Post by sysctrl2 »

Interesante Victor,
y don descargo la tExcel? :shock: :shock: :shock: :shock:
gracias !
Cesar Cortes Cruz
SysCtrl Software
Mexico

' Sin +- FWH es mejor "
User avatar
karinha
Posts: 7988
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 6 times
Contact:

Re: Exportar a Excel

Post by karinha »

sysctrl2 wrote: Sat Mar 29, 2025 6:32 pm 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#vhdRY5LU8 ... 85mTZdF_b0

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
sysctrl2
Posts: 1073
Joined: Mon Feb 05, 2007 7:15 pm
Has thanked: 8 times
Been thanked: 3 times
Contact:

Re: Exportar a Excel

Post by sysctrl2 »

Gracias Joao, que amable
vamos a probar.
Cesar Cortes Cruz
SysCtrl Software
Mexico

' Sin +- FWH es mejor "
Post Reply