feat(cupang): 출고리스트 서식 보강 (요일·머리글색·파렛트 강조)
- 시트명 20260903(목) 형식, 작성일/출고일/센터입고일에 요일 표기 - 머리글 행 배경 #DBE9F7 + 굵게 - 출고방식이 파렛트인 센터 블록 행 배경 #FAE2D5 - A열 너비 10 xlsx·구글시트 양쪽에 동일 적용(google_sheets.write_table 에 header_bg / row_highlights 인자 추가). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,16 @@ SCOPES = ["https://www.googleapis.com/auth/spreadsheets"]
|
||||
TOKEN_URI = "https://oauth2.googleapis.com/token"
|
||||
|
||||
|
||||
def _hex_color(value: str) -> dict[str, float]:
|
||||
""""RRGGBB" → Sheets API 색상."""
|
||||
v = (value or "").lstrip("#")
|
||||
return {
|
||||
"red": int(v[0:2], 16) / 255.0,
|
||||
"green": int(v[2:4], 16) / 255.0,
|
||||
"blue": int(v[4:6], 16) / 255.0,
|
||||
}
|
||||
|
||||
|
||||
class GoogleSheetsWriter:
|
||||
"""시트 1장을 통째로 다시 쓰는 용도의 얇은 래퍼."""
|
||||
|
||||
@@ -157,10 +167,13 @@ class GoogleSheetsWriter:
|
||||
last_col: int,
|
||||
title_row: int,
|
||||
widths: dict[int, int],
|
||||
header_bg: str = "",
|
||||
row_highlights: list[tuple[int, int, str]] | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""시트를 만들고(있으면 비우고) 표를 통째로 기록한다.
|
||||
|
||||
좌표는 모두 1-based(엑셀과 동일). 반환값에 시트 URL 을 담는다.
|
||||
header_bg / row_highlights 의 색은 "RRGGBB" 16진 문자열.
|
||||
"""
|
||||
if not self.enabled:
|
||||
raise RuntimeError(self.reason or "Google Sheets 미설정")
|
||||
@@ -213,12 +226,19 @@ class GoogleSheetsWriter:
|
||||
"textFormat": {"bold": True, "fontSize": 16}},
|
||||
"userEnteredFormat(horizontalAlignment,verticalAlignment,textFormat)",
|
||||
))
|
||||
requests.append(_fmt(
|
||||
header_row, first_col, header_row, last_col,
|
||||
{"horizontalAlignment": "CENTER", "verticalAlignment": "MIDDLE",
|
||||
"textFormat": {"bold": True}},
|
||||
"userEnteredFormat(horizontalAlignment,verticalAlignment,textFormat)",
|
||||
))
|
||||
header_fmt: dict[str, Any] = {
|
||||
"horizontalAlignment": "CENTER", "verticalAlignment": "MIDDLE",
|
||||
"textFormat": {"bold": True},
|
||||
}
|
||||
header_fields = "userEnteredFormat(horizontalAlignment,verticalAlignment,textFormat)"
|
||||
if header_bg:
|
||||
header_fmt["backgroundColor"] = _hex_color(header_bg)
|
||||
header_fields = (
|
||||
"userEnteredFormat(horizontalAlignment,verticalAlignment,"
|
||||
"textFormat,backgroundColor)"
|
||||
)
|
||||
requests.append(_fmt(header_row, first_col, header_row, last_col,
|
||||
header_fmt, header_fields))
|
||||
if last_row >= first_data_row:
|
||||
requests.append(_fmt(
|
||||
first_data_row, first_col, last_row, last_col,
|
||||
@@ -245,6 +265,14 @@ class GoogleSheetsWriter:
|
||||
}
|
||||
})
|
||||
|
||||
# 특정 행 구간 배경색(예: 파렛트 출고 블록)
|
||||
for (r1, r2, color) in (row_highlights or []):
|
||||
requests.append(_fmt(
|
||||
r1, first_col, r2, last_col,
|
||||
{"backgroundColor": _hex_color(color)},
|
||||
"userEnteredFormat(backgroundColor)",
|
||||
))
|
||||
|
||||
for col, width in widths.items():
|
||||
requests.append({
|
||||
"updateDimensionProperties": {
|
||||
|
||||
Reference in New Issue
Block a user