forked from geekcomputers/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
write_excel_file.py
40 lines (32 loc) · 1.08 KB
/
write_excel_file.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import xlwt
import openpyxl
# Workbook is created
xlwt_wb = xlwt.Workbook()
# add_sheet is used to create sheet.
sheet1 = xlwt_wb.add_sheet("Sheet 1")
sheet1.write(1, 0, "ISBT DEHRADUN")
sheet1.write(2, 0, "SHASTRADHARA")
sheet1.write(3, 0, "CLEMEN TOWN")
sheet1.write(4, 0, "RAJPUR ROAD")
sheet1.write(5, 0, "CLOCK TOWER")
sheet1.write(0, 1, "ISBT DEHRADUN")
sheet1.write(0, 2, "SHASTRADHARA")
sheet1.write(0, 3, "CLEMEN TOWN")
sheet1.write(0, 4, "RAJPUR ROAD")
sheet1.write(0, 5, "CLOCK TOWER")
xlwt_wb.save("xlwt example.xls")
# Workbook is created
openpyxl_wb = openpyxl.Workbook()
# create_sheet is used to create sheet.
sheet1 = openpyxl_wb.create_sheet("Sheet 1", index=0)
sheet1.cell(1, 1, "ISBT DEHRADUN")
sheet1.cell(2, 1, "SHASTRADHARA")
sheet1.cell(3, 1, "CLEMEN TOWN")
sheet1.cell(4, 1, "RAJPUR ROAD")
sheet1.cell(5, 1, "CLOCK TOWER")
sheet1.cell(1, 2, "ISBT DEHRADUN")
sheet1.cell(1, 3, "SHASTRADHARA")
sheet1.cell(1, 4, "CLEMEN TOWN")
sheet1.cell(1, 5, "RAJPUR ROAD")
sheet1.cell(1, 6, "CLOCK TOWER")
openpyxl_wb.save("openpyxl example.xlsx")