workbook = xlsxwriter.Workbook('myfile.xlsx')
worksheet = workbook.add_worksheet()
row = 0
col = 0
order = sorted(d.keys())
for key in order:
    row += 1
print(key)
worksheet.write(row, col, key)
for item in d[key]:
    print((item, row, col + 1))
worksheet.write(row, col + 1, item)
col += 1
col = 0
workbook.close()
How to dump a dictionary into an .xlsx file with proper column alignment?