Revisando los mensajes vi tu trabajo. Has hecho algo mas al respecto. Te
funcionó todo. Me podrías comentar como tienes lo que has hecho, ya que
tengo que hacer algo parecido y quiero ver si me puedes facilitar el
tragajo.

Saludos
Andrés

2009/5/22 Antonio Martinez <[email protected]>

>
> Como comente anteriormente el AutomateIt parece que no funciona...
>
> He empezado a desarrollar un layer (o capa) para que escribiendo codigo OLE
> Excel se traduzca a OLE Calc... no se como terminara la empresa... ahi va
> lo
> que llevo desarrollado (el lenguaje es xHarbour)
>
> #Define lSISTEMA_CALC .T.
>
> //--------------------------------------------------------------------------
> //
> FUNCTION CreateObjectExcelLayer()
> Local oExcel:= NIL
> Local oErr:= NIL
> IF !lSISTEMA_CALC
>   TRY
>       // Siempre crea objeto (evito algunos problemas pe. en saveas())
>       oExcel:= CreateObject( "Excel.Application" )
>   CATCH oErr
>       MERROR_( "­ No se pudo conectar con Excel !", OLE2TXTERROR(),
> oExcel,;
>                oErr:SubSystem(),;
>                oErr:Description,;
>                oErr:Operation )
>       oExcel:= NIL
>   END
> ELSE
>   oExcel:= TExcelLayer():New()
> ENDIF
> RETURN oExcel
> *
>
>
> //--------------------------------------------------------------------------
> //
> CLASS TExcelLayer
>
>  METHOD New()
>
> //  ASSIGN Visible(x) INLINE (msginfo("hola", x))
>  METHOD Get(cMessage) //INLINE msginfo(cMessage, "falta implementar !")
>
>
>  // Datas Excel simuladas ----------------------------------------
>  // Estas datas seran las que se manjen desde fuera... pero aqui
>  // dentro deben tener valores apropiados
>  DATA oSheet
>  DATA WorkBooks
>  DATA TmpWorkSheets        HIDDEN
>  METHOD WorkSheets(nSheet)
>
>  #Define ACTIVE_SHEET ::oOOCalc:getCurrentController():getActiveSheet()
>  ACCESS ActiveSheet INLINE TWorkSheetExcelLayer():New(Self, NIL, NIL,
> ACTIVE_SHEET)
>
>  //---------------------------------------------------------------
>
>  // Datas Calc reales --------------------------------------------
>     DATA oOOEngine         READONLY
>     DATA oOOCore           READONLY
>     DATA oOODesktop        READONLY
>     DATA oOOCalc           READONLY
>  //---------------------------------------------------------------
>
> ENDCLASS
> *
>
> //--------------------------------------------------------------------------
> //
> METHOD WorkSheets(nSheet)
> Local xRet:= NIL
> #Define lCOMO_DATA PCount() == 0
> IF lCOMO_DATA
>   xRet:= ::TmpWorkSheets
> ELSE
>   xRet:= TWorkSheetExcelLayer():New(Self, NIL, nSheet- 1)
> ENDIF
> RETURN xRet
>
> //--------------------------------------------------------------------------
> //
> METHOD Get(cMessage)
> cMessage:= Upper(cMessage)
> DO CASE
>   CASE cMessage == "ACTIVESHEET"
>      xRet:= ::ActiveSheet
>      *
>   CASE .T.
>      MERROR_("Falta implementar mensaje", cMessage)
> ENDCASE
> RETURN xRet
> *
>
> //--------------------------------------------------------------------------
> //
> METHOD New() CLASS TExcelLayer
> Local oErr
> *
> TRY
>    ::oOOEngine:= CreateObject( "com.sun.star.ServiceManager" )
> CATCH oErr
>    MERROR_( "­ No se pudo conectar con Open Office !", OLE2TXTERROR(),
> ::oOOEngine,;
>             oErr:SubSystem(),;
>             oErr:Description,;
>             oErr:Operation )
>    RETURN NIL
> END
> ::oOOcore   :=
> ::oOOEngine:CreateInstance("com.sun.star.refelection.CoreReflection")
> ::oOODesktop := ::oOOEngine:createInstance("com.sun.star.frame.Desktop")
> *
> ::oOOCalc := ::oOODesktop:loadComponentFromURL("private:factory/scalc",
> "_blank", 0, {})
>
> ::WorkBooks := TWorkBooksExcelLayer():New(Self)
> ::TmpWorkSheets:= TWorkSheetsExcelLayer():New(Self)
> RETURN Self
> *
> *
> *
>
> //--------------------------------------------------------------------------
> //
>
>
> //--------------------------------------------------------------------------
> //
> CLASS TWorkBooksExcelLayer
>
>
>   EXPORTED:
>      METHOD New()
>      METHOD Add()
>
>   HIDDEN:
>      DATA oExcelLayer
> ENDCLASS
>
>
> //--------------------------------------------------------------------------
> //
> METHOD New(oExcelLayer) CLASS TWorkBooksExcelLayer
> ::oExcelLayer:= oExcelLayer
> RETURN Self
>
>
> //--------------------------------------------------------------------------
> //
> METHOD Add() CLASS TWorkBooksExcelLayer
> Local oBook
> oBook:= TWorkBookExcelLayer():New(::oExcelLayer) //, Self)
> RETURN oBook
>
> //--------------------------------------------------------------------------
> //
> CLASS TWorkBookExcelLayer
>   EXPORTED:
>      METHOD New()
>   HIDDEN:
>      DATA oExcelLayer
>      DATA oWorkBooksExcelLayer
> ENDCLASS
>
> //--------------------------------------------------------------------------
> //
> METHOD New(oExcelLayer, oWorkBooksExcelLayer) CLASS TWorkBookExcelLayer
> ::oExcelLayer         := oExcelLayer
> ::oWorkBooksExcelLayer:= oWorkBooksExcelLayer
> RETURN Self
>
>
>
> //--------------------------------------------------------------------------
> //
> CLASS TWorkSheetsExcelLayer
>
>
>   EXPORTED:
>      METHOD New()
> //      // -1 pq parece que indica una hoja mas de la cuenta !!!
> //      ACCESS Count  INLINE Len( ::oExcelLayer:oOOCalc:getSheets() )- 1
>      ACCESS Count  INLINE ::oExcelLayer:oOOCalc:getSheets():getCount()
>   HIDDEN:
>      DATA oExcelLayer
>
> ENDCLASS
>
>
> //--------------------------------------------------------------------------
> //
> METHOD New(oExcelLayer) CLASS TWorkSheetsExcelLayer
> ::oExcelLayer:= oExcelLayer
> RETURN Self
> *
>
> //--------------------------------------------------------------------------
> //
> CLASS TWorkSheetExcelLayer
>   EXPORTED:
>      METHOD New()
>      METHOD Delete() INLINE
> ::oExcelLayer:oOOCalc:getSheets():removeByName(::oOOSheet:Name  )
>      ACCESS Name        INLINE ::oOOSheet:Name
>      ASSIGN Name(cName) INLINE ::oOOSheet:Name:= cName
>   HIDDEN:
>      DATA oExcelLayer
>      DATA oWorkSheetsExcelLayer
>      DATA nSheet
>
>      DATA oOOSheet
>
> ENDCLASS
>
> //--------------------------------------------------------------------------
> //
> METHOD New(oExcelLayer, oWorkSheetsExcelLayer, nSheet, oOOSheet) CLASS
> TWorkSheetExcelLayer
> ::oExcelLayer          := oExcelLayer
> ::oWorkSheetsExcelLayer:= oWorkSheetsExcelLayer
> ::nSheet               := nSheet
> DO CASE
>   CASE ::nSheet != NIL
>      ::oOOSheet:= ::oExcelLayer:oOOCalc:getSheets():getByIndex(nSheet)
>   CASE oOOSheet != NIL
>      ::oOOSheet:= oOOSheet
> ENDCASE
> RETURN Self
>
>
>
>
>
> Saludos
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Responder a