Você está na página 1de 2

import tkinter as tk

from tkinter import filedialog


import csv, random
from openpyxl import Workbook
from openpyxl import load_workbook
from openpyxl.styles import Style, PatternFill, Border, Side, Alignment,
Protection, Font, Color

wb = Workbook()
ws = wb.active

ultima = 25

self.p.adiciona_linha()
for i in range(ultima+1):
texto = "cp-liso" + ("%d" % i) + ".xlsx"
self.p.adiciona_texto(texto)
self.p.adiciona_texto(texto)

self.p.adiciona_linha()

endereco_arquivo = '$A$1&B$6'
for i in range(ultima+1):
coluna = self.p.coluna(i)
intervalo_origem = '$b$1:$b$23'
intervalo_local = 'B7:B29'
endereco_local_formula = 'B7'
ws[endereco_local_formula] = formula
formula = '=DDE("soffice",'+ \
endereco_arquivo + \
',"Sheet.' + \
intervalo_origem + '")'
ws.formula_attributes[endereco_local_formula] = \
{'t': 'array', 'ref': intervalo_local}

def coluna(self, c, fixo = False):


col = ""
if (c > 702):
cent = c / 702
col = col + chr(64+cent)
c = c - (cent * 702)
if (c > 26):
dez = c / 26
col = col + chr(64+dez)
c = c - (dez * 26)
col = col + chr(64+c)
if fixo:
col = "$" + col
return col

def linha(self, l, fixo = False):


lin = ("%d", l)
if fixo:
lin = "$" + lin
return lin

def celula(self, l, c, fixa_lin = False, fixa_col = False):


col = self.coluna(c, fixa_col)
lin = self.linha(l, fixa_lin)
cel = col + lin
return cel

def intervalo(self, li,ci, lf,cf, ):


ci = self.p.celula(li,ci)
cf = self.p.celula(lf,cf)
return ci+":"+cf

Você também pode gostar