I have an excel sheet with two different columns from where I want to take data one at a time say data value from A2 and B2 then perform certain operation and then again take values from B3 and C3 and so on.. till B50 and C50. I have written the following code for this but I believe it's not correct. Also I am new to python so don't have much knowledge. Any help would be appreciated. Thanks in advance!
wb = openpyxl.load_workbook('Inputexcel.xlsm')
sheet = wb['Sheet1']
tup1 = (sheet['A2':'A50'])
tup2 = (sheet['B2':'B50'])
for i in range(0,48):
text = tup1[i].value
i+=1
I was able to implement it for a single value and also perform the operation by using the below code. But my main aim is to iterate for all the values of excel where I am facing issue. Code for single value :
wb = openpyxl.load_workbook('Inputexcel.xlsm')
sheet = wb['Sheet1']
text = sheet['A2'].value
eid = sheet['B2'].value
Also sharing the Operation to be performed if it is of any help :
doc = docx.Document('mydoc.docx')
doc.paragraphs[9].runs[6].clear()
doc.paragraphs[9].runs[6].text
doc.paragraphs[9].add_run(text).bold = True
doc.save('mydoc ' + str(eid) + '.docx')