python and excel(doing automation)

Asked

Viewed 337 times

1

this code below it takes dice from a spreadsheet and plays on a list then want the dice from this list plays on another spreadsheet.

Until the list get but when it comes to moving to another spreadsheet I do not know how to do.. someone could help me

#coding:latin-1
import xlrd
from openpyxl import workbook
from openpyxl import open
from openpyxl import load_workbook
book=load_workbook("zanlorenzi.xlsx")


from openpyxl import Workbook


arquivo = xlrd.open_workbook('exp.xlsx')
planilha = arquivo.sheet_by_index(0)

lista_valores = planilha.col_values(0)


       #inicio do programa

def xlread(arq_xls):
    #  abre o arquivo para leitura
    xls = xlrd.open_workbook(arq_xls)
    # pega a primeira linha do arquivo
    plan = xls.sheets()[0]
    for i in range(0,plan.nrows):

      yield plan.row_values(i)


zanlorezi=[]

for i in xlread("exp.xlsx"):
    zanlorezi.append(i)
    #for a in zanlorezi:
        #print(zanlorezi)

for i in xlread("zanlorenzi.xlsx"):
     book=

    #print(i)
     book.save("zanlorenzi.xlsx")
for a in zanlorezi:

    print(a)

1 answer

1

import openpyxl

wb = openpyxl.Workbook()
ob = wb.get_sheet_by_name('xXx')
ob['c1'] = 'PYTHON' #<:--- 
ob['c1'].value

cell coordinate can be used as key of dictionary in Worksheet object to write in each cell

  • thanks just did not understand porrque "#<"

  • I can use inside the dictionary key on the Worksheet object to place a variable?

  • 1

    I indicated with an arrow arrow to the dictionary, the key and the attribute. Each key has a unique and individual name and the attribute can be repeated :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.