1# import openpyxl module
2import openpyxl
3
4# Call a Workbook() function of openpyxl
5# to create a new blank Workbook object
6wb = openpyxl.Workbook()
7
8sheet = wb.active
9
10# using sheet object's cell() method.
11c1 = sheet.cell(row = 1, column = 1)
12
13# writing values to cells
14c1.value = "ANKIT"
15
16c2 = sheet.cell(row= 1 , column = 2)
17c2.value = "RAI"
18
19c3 = sheet['A2']
20c3.value = "RAHUL"
21
22c4 = sheet['B2']
23c4.value = "RAI"
24
25# Anytime you modify the Workbook object
26# or its sheets and cells, the spreadsheet
27# file will not be saved until you call
28# the save() workbook method.
29wb.save("C:\\Users\\user\\Desktop\\demo.xlsx")
30