Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to assign the below list to a range of cells using OpenPYXL.

quarters = ['Q1', 'Q2', 'Q3', 'Q4']

I used the below to assign one value over a range, which worked fine.

for col in cpcp.iter_cols(min_row=2, max_row=3, min_col=23, max_col=55):
    for cell in col:
        cell.value = 'P'

However, I tried the below code with a List...

quarters = ['Q1', 'Q2', 'Q3', 'Q4']
for col in cpcp.iter_cols(min_row=4, max_row=4, min_col=23, max_col=54):
    for col, value in enumerate(quarters):
        cell.value = quarters

I'm getting the below error:

ValueError: Cannot convert ['Q1', 'Q2', 'Q3', 'Q4'] to Excel

Below is a snippet of what I'm trying to acheive:

enter image description here

Thanks for your help!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
2.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...