feat: Excelの罫線を引く処理を高速化。設定済みの書式を反映させていく方式にした。templateのExcelのA2セルに予め設定。

This commit is contained in:
shimoda.m@nds-tyo.co.jp 2023-09-20 16:22:21 +09:00
parent 088136d76c
commit 12744406cf
2 changed files with 4 additions and 5 deletions

View File

@ -5,7 +5,6 @@ import shutil
from datetime import datetime
import pandas as pd
from openpyxl.styles.borders import Border, Side
from src.aws.aws_api_client import AWSAPIClient
from src.aws.s3 import S3Client
@ -157,11 +156,11 @@ class BioViewService(BaseService):
# Excelに罫線を引く
workbook = writer.book
sheet = workbook['Sheet1']
side = Side(style='thin', color='000000')
border = Border(top=side, bottom=side, left=side, right=side)
for row in sheet[f'A1:AK{data_frame_range + 1}']:
# A2セルに罫線の書式を設定しておき、同じ書式を設定する
formatted_cell = sheet['A2']
for row in sheet[f'A2:AK{data_frame_range + 1}']:
for cell in row:
cell.border = border
cell._style = formatted_cell._style
data_frame_chunk_size = 2000 # 1回あたりの書き出し行数
is_first = True # ループの初回