Realizing that it has a lot of repetitive code I decided to automate it by creating a looping of reading the cells of my excel file.
#row cell fixa para o horario
rows = ts[1].rows
cells = rows[1].cells
#Segunda 7h40min - 8h30min
cell = cells[3]
t1cell13 = cell.paragraphs
t1cell13 = str(t1cell13[0].text.encode("utf-8"))
t1cell13 = unicode(t1cell13, "utf-8")
print t1cell13
w_sheet.write(8,10, t1cell13, style)
a1 = t1cell13
#terça 7h40min - 8h30min
cell = cells[4]
t1cell14 = cell.paragraphs
t1cell14 = str(t1cell14[0].text.encode("utf-8"))
t1cell14 = unicode(t1cell14, "utf-8")
w_sheet.write(9,10, t1cell14), style)
a2 = t1cell14
#Quarta 7h40min - 8h30min
cell = cells[5]
t1cell15 = cell.paragraphs
t1cell15 = str(t1cell15[0].text.encode('utf-8'))
t1cell15 = unicode(t1cell15, "utf-8")
w_sheet.write(t1cell15, style)
a3 = t1cell15
#quinta 7h40min - 8h30min
cell = cells[6]
t1cell16 = cell.paragraphs
print str(t1cell16[0].text.encode('utf-8'))
w_sheet.write(11,10, str(t1cell16[0].text), style)
a4 = str(t1cell16[0].text.encode('utf-8'))
#sexta 7h40min - 8h30min
cell = cells[7]
t1cell17 = cell.paragraphs
print str(t1cell17[0].text.encode('utf-8'))
w_sheet.write(12,10, str(t1cell17[0].text), style)
a5 = str(t1cell17[0].text.encode('utf-8'))
#Sabado 7h40min - 8h30min
cell = cells[8]
t1cell18 = cell.paragraphs
a6 = str(t1cell18[0].text.encode('utf-8'))
Doing so:
#row cell fixa para o horario
rows = ts[1].rows
cells = rows[1].cells
i = 3
j = 8
k = 1
while (i < 9):
cell = cells[(i)]
item = cell.paragraphs
item = str(item[0].text.encode("utf-8"))
item = unicode(item, "utf-8")
i = i+1
while (j < 13):
w_sheet.write((j),10, item, style)
j = j+1
while (k < 7):
a(k) = item
k = k+1
But in the final part of the while, where I try to put the (k), it is not working, I needed every lopping of the while to return: a1 = item a2 = item . . .
If you have another solution option you can also share.
Thank you very much.