Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Hugo Baur

How to maipulation excel file XLSM using Python 3

Recommended Posts

Dear, good afternoon.

I have a problem with my work and I can not solve it.

First problem: I need to read some values ​​in an xls file and place them in specific locations in an xlsm file daily.

  • I can read the values, however I can not write to the xlsm file. Gives an error

Second problem: If I change xlsm to xls I can not just put the values ​​I need, it makes a copy of all information that has no original file.

I am using xlrd as xlwt libraries

from xlrd import open_workbook
from xlwt import easyxf
from xlutils.copy import copy

rb = open_workbook('Y:/Operação/RDH/2017/01 Jan/RDH05JAN.xlsx')
sh = rb.sheet_by_index(0)
sh2 = rb.sheet_by_index(1)
sh3 = rb.sheet_by_index(2)
sh4 = rb.sheet_by_index(3)

wb = copy(rb)

ws = wb.get_sheet(0)
ws2 = wb.get_sheet(1)
ws3 = wb.get_sheet(2)
ws4 = wb.get_sheet(3)

print ("SUDESTE")
energia_armazenada_max_se = sh2.cell_value(rowx=6, colx=11)
print ("Valor: " + str(energia_armazenada_max_se))
ena_percent_mlt_se = format(sh2.cell_value(rowx=7, colx=7))
print ("Valor: " + str(ena_percent_mlt_se))
ena_total_mlt_se = format(sh2.cell_value(rowx=6, colx=7))

ws.write ( 1,0, 999999 )
ws.write ( 1, 1 , 999999 )

wb.save('Y:\TEMP\Hugo\Programação\Balanço Diário de Energia 2017.xls')

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.