diff --git a/app/integrations/google_sheets.py b/app/integrations/google_sheets.py index 00c3f84..7a50bf8 100644 --- a/app/integrations/google_sheets.py +++ b/app/integrations/google_sheets.py @@ -166,7 +166,7 @@ class GoogleSheetsWriter: first_col: int, last_col: int, title_row: int, - widths: dict[int, int], + widths: dict[int, int], # 열 번호(1-based) -> 픽셀 header_bg: str = "", row_highlights: list[tuple[int, int, str]] | None = None, ) -> dict[str, Any]: @@ -280,7 +280,7 @@ class GoogleSheetsWriter: "sheetId": sheet_id, "dimension": "COLUMNS", "startIndex": col - 1, "endIndex": col, }, - "properties": {"pixelSize": int(width) * 8}, + "properties": {"pixelSize": int(width)}, "fields": "pixelSize", } }) diff --git a/app/modules/cupang/export.py b/app/modules/cupang/export.py index cc97462..d71a414 100644 --- a/app/modules/cupang/export.py +++ b/app/modules/cupang/export.py @@ -28,7 +28,22 @@ COL_FIRST = 2 COL_LAST = 12 # 센터 단위로 병합되는 열 MERGE_COLS = (3, 4, 5, 6, 7, 11, 12) -WIDTHS = {1: 10, 2: 6, 3: 12, 4: 12, 5: 12, 6: 11, 7: 10, 8: 12, 9: 26, 10: 8, 11: 12, 12: 11} +# 열 너비 — 구글 시트 기준 픽셀. xlsx 는 문자폭(px/7)으로 환산해서 쓴다. +WIDTHS_PX = { + 1: 10, # A (여백) + 2: 45, # B 구분 + 3: 106, # C 작성일 + 4: 106, # D 출고일 + 5: 106, # E 센터입고일 + 6: 90, # F 입고센터 + 7: 80, # G 출고방식 + 8: 95, # H 제품코드 + 9: 210, # I 제품명 + 10: 60, # J 수량 + 11: 100, # K 출고 + 12: 90, # L 작업자 +} +PX_PER_CHAR = 7.0 HEADER_BG = "DBE9F7" # 머리글 행 배경 PALLET_BG = "FAE2D5" # 출고방식이 파렛트인 센터 블록 배경 PALLET_METHOD = "파렛트" @@ -168,8 +183,8 @@ def build_workbook(ship_date: str, shipments: list[dict[str, Any]]) -> Any: for col in range(COL_FIRST, COL_LAST + 1): ws.cell(row=row, column=col).fill = pallet_fill - for col, width in WIDTHS.items(): - ws.column_dimensions[get_column_letter(col)].width = width + for col, px in WIDTHS_PX.items(): + ws.column_dimensions[get_column_letter(col)].width = round(px / PX_PER_CHAR, 2) ws.row_dimensions[TITLE_ROW].height = 28 return wb diff --git a/app/modules/cupang/router.py b/app/modules/cupang/router.py index ed00eb2..cb19511 100644 --- a/app/modules/cupang/router.py +++ b/app/modules/cupang/router.py @@ -266,7 +266,7 @@ def _push_to_google_sheet(store: Any, ship_date: str) -> dict[str, Any]: from .export import ( # noqa: WPS433 COL_FIRST, COL_LAST, FIRST_DATA_ROW, HEADER_BG, HEADER_ROW, PALLET_BG, - TITLE_ROW, WIDTHS, build_table, sheet_title, + TITLE_ROW, WIDTHS_PX, build_table, sheet_title, ) spreadsheet_id = (os.getenv("CUPANG_SHEET_ID") or "").strip() @@ -294,7 +294,7 @@ def _push_to_google_sheet(store: Any, ship_date: str) -> dict[str, Any]: first_col=COL_FIRST, last_col=COL_LAST, title_row=TITLE_ROW, - widths=WIDTHS, + widths=WIDTHS_PX, header_bg=HEADER_BG, row_highlights=[(r1, r2, PALLET_BG) for (r1, r2) in table["pallet_ranges"]], )