|
1 |
| -from xlwt import Workbook |
| 1 | +import xlwt |
2 | 2 | import openpyxl
|
3 | 3 |
|
4 | 4 | # Workbook is created
|
5 |
| -wb = Workbook() |
| 5 | +xlwt_wb = xlwt.Workbook() |
6 | 6 |
|
7 | 7 | # add_sheet is used to create sheet.
|
8 |
| -sheet1 = wb.add_sheet("Sheet 1") |
| 8 | +sheet1 = xlwt_wb.add_sheet("Sheet 1") |
9 | 9 |
|
10 | 10 | sheet1.write(1, 0, "ISBT DEHRADUN")
|
11 | 11 | sheet1.write(2, 0, "SHASTRADHARA")
|
|
18 | 18 | sheet1.write(0, 4, "RAJPUR ROAD")
|
19 | 19 | sheet1.write(0, 5, "CLOCK TOWER")
|
20 | 20 |
|
21 |
| -wb.save("xlwt example.xls") |
| 21 | +xlwt_wb.save("xlwt example.xls") |
22 | 22 |
|
23 | 23 | # Workbook is created
|
24 | 24 | openpyxl_wb = openpyxl.Workbook()
|
25 | 25 |
|
26 | 26 | # create_sheet is used to create sheet.
|
27 |
| -sheet1 = openpyxl_wb.create_sheet("Sheet 1") |
| 27 | +sheet1 = openpyxl_wb.create_sheet("Sheet 1", index=0) |
28 | 28 |
|
29 | 29 | sheet1.cell(1, 1, "ISBT DEHRADUN")
|
30 | 30 | sheet1.cell(2, 1, "SHASTRADHARA")
|
31 | 31 | sheet1.cell(3, 1, "CLEMEN TOWN")
|
32 | 32 | sheet1.cell(4, 1, "RAJPUR ROAD")
|
33 | 33 | sheet1.cell(5, 1, "CLOCK TOWER")
|
34 |
| -sheet1.cell(1, 1, "ISBT DEHRADUN") |
35 |
| -sheet1.cell(1, 2, "SHASTRADHARA") |
36 |
| -sheet1.cell(1, 3, "CLEMEN TOWN") |
37 |
| -sheet1.cell(1, 4, "RAJPUR ROAD") |
38 |
| -sheet1.cell(1, 5, "CLOCK TOWER") |
| 34 | +sheet1.cell(1, 2, "ISBT DEHRADUN") |
| 35 | +sheet1.cell(1, 3, "SHASTRADHARA") |
| 36 | +sheet1.cell(1, 4, "CLEMEN TOWN") |
| 37 | +sheet1.cell(1, 5, "RAJPUR ROAD") |
| 38 | +sheet1.cell(1, 6, "CLOCK TOWER") |
39 | 39 |
|
40 | 40 | openpyxl_wb.save("openpyxl example.xlsx")
|
0 commit comments