I have a list of data which I want to write into a specific column (B2 column) in Excel
Input example:
mydata =[12,13,14,15]
Desired Output in Excel:
A2| B2|
| 12|
| 13|
| 14|
| 15|
I have tried using openpyxl to access the specific sheet (which works fine) and specific cell(B2) but it throws an error to write to the excel file as it is a list. It works fine if I assign a single value as shown in the code extract below:
mydata= my_wb['sheet2']['B2'] = 4
Can anyone point me in the right direction?
CodePudding user response:
Iterate over the list and paste each value into the desired row in column B:
for i, n in enumerate(mydata):
my_wb["sheet2"].cell(i 2, 2).value = n