fix(cupang): 열 너비를 픽셀 기준으로 (A=10, C·D·E=106)
구글 시트 요청에 pixelSize 를 8배로 넣어 A열이 80px 로 벌어져 있었다. WIDTHS_PX 를 픽셀 그대로 쓰고, xlsx 는 px/7 로 환산한다. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -166,7 +166,7 @@ class GoogleSheetsWriter:
|
|||||||
first_col: int,
|
first_col: int,
|
||||||
last_col: int,
|
last_col: int,
|
||||||
title_row: int,
|
title_row: int,
|
||||||
widths: dict[int, int],
|
widths: dict[int, int], # 열 번호(1-based) -> 픽셀
|
||||||
header_bg: str = "",
|
header_bg: str = "",
|
||||||
row_highlights: list[tuple[int, int, str]] | None = None,
|
row_highlights: list[tuple[int, int, str]] | None = None,
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
@@ -280,7 +280,7 @@ class GoogleSheetsWriter:
|
|||||||
"sheetId": sheet_id, "dimension": "COLUMNS",
|
"sheetId": sheet_id, "dimension": "COLUMNS",
|
||||||
"startIndex": col - 1, "endIndex": col,
|
"startIndex": col - 1, "endIndex": col,
|
||||||
},
|
},
|
||||||
"properties": {"pixelSize": int(width) * 8},
|
"properties": {"pixelSize": int(width)},
|
||||||
"fields": "pixelSize",
|
"fields": "pixelSize",
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -28,7 +28,22 @@ COL_FIRST = 2
|
|||||||
COL_LAST = 12
|
COL_LAST = 12
|
||||||
# 센터 단위로 병합되는 열
|
# 센터 단위로 병합되는 열
|
||||||
MERGE_COLS = (3, 4, 5, 6, 7, 11, 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" # 머리글 행 배경
|
HEADER_BG = "DBE9F7" # 머리글 행 배경
|
||||||
PALLET_BG = "FAE2D5" # 출고방식이 파렛트인 센터 블록 배경
|
PALLET_BG = "FAE2D5" # 출고방식이 파렛트인 센터 블록 배경
|
||||||
PALLET_METHOD = "파렛트"
|
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):
|
for col in range(COL_FIRST, COL_LAST + 1):
|
||||||
ws.cell(row=row, column=col).fill = pallet_fill
|
ws.cell(row=row, column=col).fill = pallet_fill
|
||||||
|
|
||||||
for col, width in WIDTHS.items():
|
for col, px in WIDTHS_PX.items():
|
||||||
ws.column_dimensions[get_column_letter(col)].width = width
|
ws.column_dimensions[get_column_letter(col)].width = round(px / PX_PER_CHAR, 2)
|
||||||
ws.row_dimensions[TITLE_ROW].height = 28
|
ws.row_dimensions[TITLE_ROW].height = 28
|
||||||
|
|
||||||
return wb
|
return wb
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ def _push_to_google_sheet(store: Any, ship_date: str) -> dict[str, Any]:
|
|||||||
|
|
||||||
from .export import ( # noqa: WPS433
|
from .export import ( # noqa: WPS433
|
||||||
COL_FIRST, COL_LAST, FIRST_DATA_ROW, HEADER_BG, HEADER_ROW, PALLET_BG,
|
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()
|
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,
|
first_col=COL_FIRST,
|
||||||
last_col=COL_LAST,
|
last_col=COL_LAST,
|
||||||
title_row=TITLE_ROW,
|
title_row=TITLE_ROW,
|
||||||
widths=WIDTHS,
|
widths=WIDTHS_PX,
|
||||||
header_bg=HEADER_BG,
|
header_bg=HEADER_BG,
|
||||||
row_highlights=[(r1, r2, PALLET_BG) for (r1, r2) in table["pallet_ranges"]],
|
row_highlights=[(r1, r2, PALLET_BG) for (r1, r2) in table["pallet_ranges"]],
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user