Amados e honoráveis membros da lista,
É com muito prazer que venho divulgar uma script em Python, para aqueles que
estiverem interessados em tirar do Ooo mais do que o BASIC pode oferecer em sua
fraqueza estrutural.
Esta script aborda dois problemas muito comuns para quem vai ler arquivos:
1. Leitura sequencial;
2. Leitura ODBC;
Eu apenas peguei a script HelloWorld que está no caminho:
<raiz Ooo>\share\Scripts\python
modifiquei para:
# HelloWorld python script for the scripting framework
import os, sys, odbc, dbi
def LeArqPython( ):
"""Prints the string 'Hello World(in Python)' into the current document"""
#get the doc from the scripting context which is made available to all scripts
model = XSCRIPTCONTEXT.getDocument()
#get the XText interface
text = model.Text
#create an XTextCursor
cursor = text.createTextCursor()
#and insert the string
text.insertString( cursor, 'LEITURA SEQUENCIAL', 0 )
f = open('C:\out.txt','r')
for lin in f:
text.insertString( cursor, lin, 0 )
f.close()
text.insertString( cursor, 'LEITURA ODBC', 0 )
conn = odbc.odbc('Juris')
cur = conn.cursor()
cur.execute('Select Id, Nome From Advogados')
dados = cur.fetchall()
for lin in dados:
text.insertString( cursor, lin[1] + '\n', 0 )
cur.close()
conn.close()
return None
Aconselho utilizarem o editor do Python, por causa das tabulações. É só baixar o
Python no www.python.org, que o editor vem junto. Não editem com editores
normais.
Bernardo
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]