Ejemplo de ADO para OpenOffice Writer en Harbour MiniGUI

STATIC FUNCTION Lis_OpenOffice()
local oServiceManager,oDesktop,oDocument,oCursor

Crear_fichero()

CURSORWAIT()

// inicializa
oServiceManager := TOleAuto():New("com.sun.star.ServiceManager")
oDesktop := oServiceManager:createInstance("com.sun.star.frame.Desktop")
IF oDesktop = NIL
MsgStop('OpenOffice Calc no esta disponible','error')
RETURN Nil
ENDIF
oDocument := oDesktop:loadComponentFromURL("private:factory/swriter","_blank", 0, {})

oCursor := oDocument:Text:CreateTextCursor()
oCursor:CharFontName:="Courier"
oCursor:CharHeight:=10
oCursor:CharWeight:=150

oCursor:CharHeight:=16
oDocument:Text:InsertString(oCursor, "Suizo Pruebas"+CHR(13) , .F.)
oCursor:CharHeight:=10
oDocument:Text:InsertString(oCursor, W_Imp1.L_Version1.value+CHR(13) , .F.)
oDocument:Text:InsertString(oCursor, W_Imp1.L_Version2.value+CHR(13) , .F.)
oDocument:Text:InsertString(oCursor, W_Imp1.L_Version3.value+CHR(13) , .F.)
oDocument:Text:InsertString(oCursor, W_Imp1.L_Version4.value+CHR(13) , .F.)

LIN:=6

oDocument:Text:InsertString(oCursor, "Codigo"+CHR(13) , .F.)
oDocument:Text:InsertString(oCursor, "1º plato"+CHR(13) , .F.)
oDocument:Text:InsertString(oCursor, "2º plato"+CHR(13) , .F.)
oDocument:Text:InsertString(oCursor, "Postre"+CHR(13) , .F.)

SELEC MENUS
GO TOP
LIN:=1
DO WHILE .NOT. EOF()
DO EVENTS
IF LIN=50
InsertPageBreak( oCursor)
ENDIF
oDocument:Text:InsertString(oCursor, CodMenu+CHR(13) , .F.)
oDocument:Text:InsertString(oCursor, Comida1+CHR(13) , .F.)
oDocument:Text:InsertString(oCursor, Comida2+CHR(13) , .F.)
oDocument:Text:InsertString(oCursor, Comida3+CHR(13) , .F.)
LIN++
SKIP

ENDDO

CURSORARROW()

RETURN NIL

Function InsertPageBreak( oCursor )
Local oText := oCursor:getText( )
oText:insertControlCharacter( oCursor,0, .f.) //0-OOOtextControlCharacterPARAGRAPH_BREAK
oCursor:BreakType := 4 //4-OOOstyleBreakTypePAGE_BEFORE
Return Nil

STATIC FUNCTION Crear_fichero()
IF .NOT. FILE("MENUS.DBF")
aArq:={}
Aadd( aArq , { 'CODMENU' , 'N' , 10 , 0 } )
Aadd( aArq , { 'COMIDA1' , 'C' , 30 , 0 } )
Aadd( aArq , { 'COMIDA2' , 'C' , 30 , 0 } )
Aadd( aArq , { 'COMIDA3' , 'C' , 30 , 0 } )
DBCreate( "MENUS" , aArq )
USE MENUS
FOR N=1 TO 100
APPEND BLANK
REPLACE CODMENU WITH N
REPLACE COMIDA1 WITH "PRIMER PLATO "+LTRIM(STR(N))
REPLACE COMIDA2 WITH "SEGUNDO PLATO "+LTRIM(STR(N))
REPLACE COMIDA3 WITH "POSTRE "+LTRIM(STR(N))
NEXT
ELSE
USE MENUS
ENDIF
RETURN NIL

Mas informacion: Documentos de texto