Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a552c6f

Browse files
Python Openpyxl Create Sheet and Write
Python Openpyxl Create Sheet and Write
1 parent 64db73f commit a552c6f

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

‎main.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from xlwt import Workbook
2+
import openpyxl
3+
4+
''' Workbook is created '''
5+
wb = Workbook()
6+
7+
''' add_sheet is used to create sheet '''
8+
sheet1 = wb.add_sheet("Sheet 1")
9+
10+
sheet1.write(1, 0, "ISBT DEHRADUN")
11+
sheet1.write(2, 0, "SHASTRADHARA")
12+
sheet1.write(3, 0, "CLEMEN TOWN")
13+
sheet1.write(4, 0, "RAJPUR ROAD")
14+
sheet1.write(5, 0, "CLOCK TOWER")
15+
sheet1.write(0, 1, "ISBT DEHRADUN")
16+
sheet1.write(0, 2, "SHASTRADHARA")
17+
sheet1.write(0, 3, "CLEMEN TOWN")
18+
sheet1.write(0, 4, "RAJPUR ROAD")
19+
sheet1.write(0, 5, "CLOCK TOWER")
20+
21+
''' set file name '''
22+
wb.save("xlwt example.xls")
23+
24+
''' Workbook is created '''
25+
openpyxl_wb = openpyxl.Workbook()
26+
27+
''' create_sheet is used to create sheet '''
28+
sheet1 = openpyxl_wb.create_sheet("Sheet 1")
29+
30+
sheet1.cell(1, 1, "ISBT DEHRADUN")
31+
sheet1.cell(2, 1, "SHASTRADHARA")
32+
sheet1.cell(3, 1, "CLEMEN TOWN")
33+
sheet1.cell(4, 1, "RAJPUR ROAD")
34+
sheet1.cell(5, 1, "CLOCK TOWER")
35+
sheet1.cell(1, 1, "ISBT DEHRADUN")
36+
sheet1.cell(1, 2, "SHASTRADHARA")
37+
sheet1.cell(1, 3, "CLEMEN TOWN")
38+
sheet1.cell(1, 4, "RAJPUR ROAD")
39+
sheet1.cell(1, 5, "CLOCK TOWER")
40+
41+
''' set file name '''
42+
openpyxl_wb.save("openpyxl example.xlsx")

‎openpyxl example.xlsx

5.21 KB
Binary file not shown.

‎xlwt example.xls

5.5 KB
Binary file not shown.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /