|
@@ -92,17 +92,18 @@ class ReportFileUtils:
|
|
def insert_cells(self, ws, data, start_row, start_col, end_col):
|
|
def insert_cells(self, ws, data, start_row, start_col, end_col):
|
|
if len(data) > 0:
|
|
if len(data) > 0:
|
|
for index, v in enumerate(data):
|
|
for index, v in enumerate(data):
|
|
- y = 0
|
|
|
|
- for col in range(start_col, end_col):
|
|
|
|
- value = v[y]
|
|
|
|
- if value is None:
|
|
|
|
- value = 0
|
|
|
|
- ws.col(col).width = 150 * 30 # 定义列宽
|
|
|
|
- style = self.simple_style if y >= 3 else self.default_style
|
|
|
|
- ws.write(start_row, col, value,
|
|
|
|
- style=style)
|
|
|
|
- y += 1
|
|
|
|
- start_row += 1
|
|
|
|
|
|
+ if(len(v)) == 17:
|
|
|
|
+ y = 0
|
|
|
|
+ for col in range(start_col, end_col):
|
|
|
|
+ value = v[y]
|
|
|
|
+ if value is None:
|
|
|
|
+ value = 0
|
|
|
|
+ ws.col(col).width = 150 * 30 # 定义列宽
|
|
|
|
+ style = self.simple_style if y >= 3 else self.default_style
|
|
|
|
+ ws.write(start_row, col, value,
|
|
|
|
+ style=style)
|
|
|
|
+ y += 1
|
|
|
|
+ start_row += 1
|
|
|
|
|
|
def horizontal_space_cells(self, ws, start_row, end_row, start_col, end_col):
|
|
def horizontal_space_cells(self, ws, start_row, end_row, start_col, end_col):
|
|
"""
|
|
"""
|
|
@@ -170,8 +171,7 @@ class ReportFileUtils:
|
|
|
|
|
|
# 写入数据
|
|
# 写入数据
|
|
start_row = 1
|
|
start_row = 1
|
|
- if len(d) == len(header):
|
|
|
|
- self.insert_cells(ws, d, start_row, 0, len(d[0]))
|
|
|
|
|
|
+ self.insert_cells(ws, d, start_row, 0, len(d[0]))
|
|
self.wb.save(file_path)
|
|
self.wb.save(file_path)
|
|
|
|
|
|
|
|
|