Horas y no se deja...

Horas y no se deja...

Postby fleal » Mon Apr 10, 2006 2:11 am

Como último recurso acudo a ustedes... llevo horas con esto y simplemente no me sale.

Intento copiar una hoja del libro de excel al final del libro.
Tengo un libro con 3 hojas

Primero selecciono la hoja que voy a copiar
oExcel:ActiveWorkbook:Sheets("Hoja1"):Select()

Ahora intento copiarla al final
oExcel:ActiveWorkbook:Sheets("Hoja1"):Copy("After")

Según VB se hace asi, pero no tengo idea de como implementar lo último
Sheets("Hoja1").Copy After:=Sheets(3)

¿Alguna alma caritativa que pueda ayudarme?
Fivewin 2.7 + Harbour

Gracias
Fernando Leal
fleal
 
Posts: 234
Joined: Tue Oct 25, 2005 12:39 am
Location: México, DF

y otras horas más tarde

Postby fleal » Mon Apr 10, 2006 6:26 am

Si a alguien le sirve lo he resuelto asi:

Activar la hoja que necesito, en este caso se llama "A"
oExcel:ActiveWorkbook:Sheets("A"):Select()

Agrego las hojas que necesito en el libro
RESUVD->( dbgotop() )
FOR i := 1 TO RESUVD->( lastrec() -1 )
oExcel:ActiveWorkbook:Sheets("A"):Invoke("Copy",oHoja)
NEXT

Ahora las renombro como yo quiero
nRows := RESUVD->( lastrec() )

while RESUVD->( !eof() )
if nRows == 1
oExcel:ActiveWorkbook:Sheets("A"):Select()
oExcel:ActiveWorkbook:Sheets("A"):Name := alltrim( RESUVD->FOLIBNX )

else
oExcel:ActiveWorkbook:Sheets("A ("+alltrim( cValToChar( nRows ) )+")"):Select()
oExcel:ActiveWorkbook:Sheets("A ("+alltrim( cValToChar( nRows ) )+")"):Name := alltrim( RESUVD->FOLIBNX )

endif

Activo la hoja para meterle los datos
oHoja := oExcel:Get( "ActiveSheet" )
if VD->( dbseek( RESUVD->FOLSICRE ) )
Le meto los datos que necesito...
oHoja:Cells( 8, 6 ):Value := VD->CNOMVISITA
oHoja:Cells( 8, 25 ):Value := VD->FOLIBNX


Ingo a su male el problema... vamonos con lo que sigue que es para hoy.
fleal
 
Posts: 234
Joined: Tue Oct 25, 2005 12:39 am
Location: México, DF

Postby Antonio Linares » Mon Apr 10, 2006 9:58 am

Fernando,

gracias por compartirlo con todos :)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41348
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Vikthor » Mon Apr 10, 2006 12:49 pm

Mi estimado Fer :

Te puedes ahorrar muchos tiempo si revisas el código fuente de la clase TExcel :

Code: Select all  Expand view
  /*
   * Metodos para las propiedades de la hoja
   */
  METHOD AddSheet()         INLINE ::oExcel:Sheets:Add()
  METHOD CopySheet()        INLINE ::oExcel:Sheets:Copy()
  METHOD DelSheet(cSheet)   INLINE ::oExcel:Sheets(cSheet):Delete()

  // cPos -> "After" | "Before"
  METHOD MoveSheet(cSheet,cPos,nSheet)  INLINE ::oExcel:Sheets(cSheet):Move(cPos,nSheet)
*   oSheet := oExcel:Sheets(“oSheet1”)                              //move sheet position. This example will move
*   oExcel:Sheets( "oSheet2” ):Move( oSheet )

  METHOD SetSheet(cSheet)               INLINE ::oExcel:Sheets(cSheet):Select() , ::oSheet := ::oExcel:Get( "ActiveSheet" )
  METHOD NameSheet(cSheet,cName)        INLINE ::oExcel:Sheets(cSheet):Name := cName
Vikthor
User avatar
Vikthor
 
Posts: 271
Joined: Fri Oct 07, 2005 5:20 am
Location: México


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 17 guests