import openpyxl
work_book=openpyxl.Workbook()
work_sheet=work_book.active
data=[["Champion","Year"],
['Uruguay', 1930],
['Italy', 1934],
['Italy', 1938],
['Uruguay', 1950],
['Germany', 1954],
['Brazil', 1958],
['Brazil', 1962],
['England', 1966],
['Brazil', 1970],
['Germany', 1974],
['Argentina',1978],
['Italy', 1982],
['Argentina',1986],
['Germany', 1990],
['Brazil', 1994],
['France', 1998],
['Brazil', 2002],
['Italy', 2006],
['Spain', 2010],
['Germany', 2014],
['France', 2018],
['Argentina',2022]]
for r in data:
work_sheet.append(r)
#save the work book
work_book.save(r'C:\Users\allso\Desktop\new vba projects\openpyxl\world_cup.xlsx')
Saturday, August 12, 2023
Writing a list of lists in an excel file using openpyxl
Subscribe to:
Posts (Atom)