From 388ddd96ba444f7523e239aa9ef98e6928d520a9 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 30 Oct 2023 08:36:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E7=9A=84=E6=96=87=E4=BB=B6=E5=A4=B9=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/utils/export.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/utils/export.py b/apps/utils/export.py index 16f29558..8ace324d 100644 --- a/apps/utils/export.py +++ b/apps/utils/export.py @@ -26,7 +26,8 @@ def export_excel(field_data: list, data: list, FileName: str): :return:返回文件的下载url完整路径 """ wbk = xlwt.Workbook(encoding='utf-8') - sheet = wbk.add_sheet('Sheet1', cell_overwrite_ok=True) # 第二参数用于确认同一个cell单元是否可以重设值。 + # 第二参数用于确认同一个cell单元是否可以重设值。 + sheet = wbk.add_sheet('Sheet1', cell_overwrite_ok=True) style = xlwt.XFStyle() # 赋值style为XFStyle(),初始化样式 # 设置居中 wbk.set_colour_RGB(0x23, 0, 60, 139) @@ -62,7 +63,8 @@ def export_excel(field_data: list, data: list, FileName: str): style.font = tab_fnt # 设置单元格内字体样式 style.borders = tab_borders for index, ele in enumerate(field_data): - sheet.write_merge(0, 0, index, index, ele, style) # (列开始, 列结束, 行开始, 行结束, '数据内容') + # (列开始, 列结束, 行开始, 行结束, '数据内容') + sheet.write_merge(0, 0, index, index, ele, style) # 确定栏位宽度 col_width = [] @@ -147,7 +149,7 @@ def export_excel_img(field_data: list, data: list, FileName: str): img.width, img.height = (90, 90) imgs.append((img, field_data[i2]['letter'] + str(i1+2))) except: # 这里先不做处理 - pass + pass else: cell.value = v2 @@ -155,7 +157,7 @@ def export_excel_img(field_data: list, data: list, FileName: str): ws.add_image(i[0], i[1]) FileNameF = FileName + datetime.now().strftime('%Y%m%d%H%M%S') + '.xlsx' - path = '/temp/' + path = '/media/temp/' pathRoot = settings.BASE_DIR + path if not os.path.exists(pathRoot): os.makedirs(pathRoot)