I'm asking how to save data using openpyxl!

Asked 2 years ago, Updated 2 years ago, 17 views

Data processed using for statement

ex)

x1= []

for i in range(5):

    x1.append(random.uniform(0,10))

How can I input the 10 values from into each cell of the Excel...?

I can't input all of them randomly. I'm asking because I don't understand the examples and what I explained in openpyxl!

Thank you

python

2022-09-22 13:53

1 Answers

import random
from openpyxl import Workbook
from openpyxl.compat import range

from openpyxl.utils import get_column_letter
wb = Workbook()
dest_filename = 'Hash_Code.xlsx'
ws1 = wb.active
ws1.title = "Kwak_Sung_Il"
x1 = list()
for i in range(5):
    x1.append(random.uniform(0, 10))

print(x1)

for i in "ABCDE":
    tmp = i+"1"
    ws1[tmp] = x1.pop(0)
wb.save(filename=dest_filename)



I purposely put in a familiar sentence. Just in case you misunderstand


2022-09-22 13:53

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.