import openpyxl # create empty workbook wb = openpyxl.workbook.Workbook() # remove default sheet: "Sheet" del wb['Sheet'] # Create sheet with name of our choice s = wb.create_sheet("MySheet") # We can write into cells in two ways: # 1. Use 'A1', 'B1', etc s['A1'] = 'left top' s['B1'] = 'in col B' # or we use integer indices for rows and columns ('A1' is row 1 and column 1) s.cell(row=2, column=1).value = "I am A2" s.cell(row=2, column=2).value = "I am B2" # for example to store multiple numbers in column D for i in range(1, 9): dataforthiscell = i**2 # some fake data s.cell(row=i, column=4).value = dataforthiscell # at the end, create the file, save the data (this lso closes the file after saving) wb.save('write-sample.xlsx')