#!/usr/bin/env python3
"""讀取更多資料"""
from google.oauth2 import service_account
from googleapiclient.discovery import build

SPREADSHEET_ID = '1Y708RZgZHL3Gqah9ujiw5brMuxAoW3RFl0txfXq8qrE'
creds = service_account.Credentials.from_service_account_file(
    'service_account_key.json',
    scopes=['https://www.googleapis.com/auth/spreadsheets']
)
service = build('sheets', 'v4', credentials=creds)

# 補休登記表完整 (更多行)
print('=== 補休登記表完整 ===')
result = service.spreadsheets().values().get(
    spreadsheetId=SPREADSHEET_ID,
    range='2026年加班選擇補休登記表!A1:H60'
).execute()
rows = result.get('values', [])
for i, row in enumerate(rows):
    print(f"  Row {i+1} (idx {i}): {row}")

# 讀取各月份 OT 行的 O 欄 (選擇補休)
for month in ['2026.01', '2026.02', '2026.03']:
    print(f'\n=== {month} D=上班日加班 with O column ===')
    result = service.spreadsheets().values().get(
        spreadsheetId=SPREADSHEET_ID,
        range=f'{month}!A1:O100'
    ).execute()
    rows = result.get('values', [])
    for i, row in enumerate(rows[1:], 2):
        while len(row) < 15:
            row.append('')
        if '上班日加班' in str(row[3]):
            l_val = row[11] if len(row) > 11 else ''
            o_val = row[14] if len(row) > 14 else ''
            print(f"  Row {i}: B={row[1]}, E={row[4]}, F={row[5]}, H={row[7]}, L={l_val}, O={o_val}")
