-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexcel.py
45 lines (32 loc) · 900 Bytes
/
excel.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
41
42
43
44
45
from enum import Enum
from typing import List
from xlwt import Workbook
class Type(Enum):
TEXT = 1
VALUE = 2
RESULT = 3
class BaseNode():
type = Type.TEXT
def getText(self) -> str:
pass
def getValue(self) -> int:
return 0
class BaseLine:
def getList(self) -> List[BaseNode]:
pass
def parse(self) -> None:
pass
def addEnd(self, text: str) -> None:
pass
class BaseExcel:
def __init__(self) -> None:
self.workbook = Workbook(encoding="utf-8")
self.sheet = self.workbook.add_sheet("free")
def initExcel(self, lines: List[BaseLine]):
for i in range(len(lines)):
list = lines[i].getList()
for j in range(len(list)):
n = list[j]
self.sheet.write(i, j, n.getText())
def outPutExcel(self):
self.workbook.save("./result.xlsx")