21.12.2022 Views

python_para_desenvolvedores_2ed

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

BrOffice.org 313

for lin in xrange(1, 6):

# Numera as linhas

sheet.getCellByPosition(0, lin).setValue(lin)

# Coloca somatórios no fim de cada linha

formula = '=SUM(B%d:D%d)' % (lin + 1, lin + 1)

sheet.getCellByPosition(4, lin).setFormula(formula)

# Preenche os dados

for col in (1, 2, 3):

sheet.getCellByPosition(col, lin).setFormula('=10*RAND()')

# Substitui a fórmula pelo valor

val = sheet.getCellByPosition(col, lin).getValue()

sheet.getCellByPosition(col, lin).setValue(val)

return None

Saída:

Para que o BrOffice.org possa identificar o script escrito em Python como um

arquivo de macro, ele precisa estar na pasta para scripts em Python, que no

Windows fica em “Basis\share\Scripts\python”, dentro da pasta de

instalação do BrOffice.org.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!