-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakexls.py
More file actions
44 lines (31 loc) · 920 Bytes
/
makexls.py
File metadata and controls
44 lines (31 loc) · 920 Bytes
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
41
42
43
44
# coding:utf-8
from openpyxl import Workbook
# from openpyxl.compat import range
# from openpyxl.utils import get_column_letter
def init_column_1(ws):
ws.title = "person"
ws['A1'] = ''
ws['B1'] = '姓名'
ws['C1'] = '性别'
ws['D1'] = '年龄'
def create_workbook(filename):
wb = Workbook()
ws1 = wb.active
init_column_1(ws1)
a = Person()
for i in a.make_item():
# print("writing ", i)
ws1.append(i)
wb.save(filename=filename)
if __name__ == "__main__":
create_workbook("person.xlsx")
# for row in range(1, 40):
# ws1.append(range(600))
# ws2 = wb.create_sheet(title="Pi")
# ws2['F5'] = 3.14
# ws3 = wb.create_sheet(title="Data")
# for row in range(10, 20):
# for col in range(27, 54):
# _ = ws3.cell(column=col, row=row, value="{0}".format(get_column_letter(col)))
# print(ws3['AA10'].value)
# wb.save(filename=dst_filename)