나는 내 자신의 Google 스프레드 시트 래퍼를 작성하려고 노력해 왔으며 지금까지 좌절스러운 경험이었습니다. 내가 지금 붙어있는 것은 시트 데이터의 대칭 인/아웃 형식을 얻는 방법입니다.Google 스프레드 시트 API v4에서 셀의 서식 지정 정보를 가져 오는 방법에 대한 Python 예제는 무엇입니까?
기본적으로 values (). get()을 호출하고 결과 해시를 변경 한 다음 동일한 해시를 update()까지 다시 보내려고합니다.
batchUpdate()가 필요로하는 구조체에 값(). get()의 출력을 처리하거나 강요하는 자체 솔루션을 작성해 주겠다. 할 각 셀의 서식 정보가 필요하다. 그.
이import requests
import json
from oauth2client.service_account import ServiceAccountCredentials
from apiclient.discovery import build
#Set up credentials object
auth_key_url = "<JSON CREDENTIALS FILE>"
file_contents = requests.get(auth_key_url).content
key_dict = json.loads(file_contents)
creds = ServiceAccountCredentials.from_json_keyfile_dict(key_dict, ['https://spreadsheets.google.com/feeds'])
#Now build the API object
discoveryUrl = "https://sheets.googleapis.com/$discovery/rest?version=v4"
gsheet = build('sheets', 'v4', discoveryServiceUrl=discoveryUrl, credentials=creds)
result = gsheet.spreadsheets().values().get(spreadsheetId="<A SHEET ID>", range="Sheet1!A1:ZZ").execute()
이 "결과를"생산, 사전을 함께 :
bod = {
'updateCells': {
'start': {
'sheetId': 0,
'rowIndex': 7,
'columnIndex': 0
},
'rows': [
{
'values': [
{
"userEnteredValue": {
'stringValue': 'LOL'
},
"userEnteredFormat": {
'backgroundColor': {
'red': .2,
'blue': .75,
'green': .75
}
}
},
{
"userEnteredValue": {
'stringValue': 'LOL2'
},
"userEnteredFormat": {
'backgroundColor': {
'red': .2,
'blue': 1,
'green': .75
}
}
},
{
"userEnteredValue": {
'stringValue': 'LOL3'
},
"userEnteredFormat": {
'backgroundColor': {
'red': .2,
'blue': 1,
'green': 1
}
}
}
]
}
],
'fields': 'userEnteredValue,userEnteredFormat.backgroundColor'
}
}
내가 값을 검색하고있어 어떻게 현재 다음과 같은 :
의 batchUpdate()이 같은 서식 정보가 예상 2 개의 키, "범위"및 "값", "값"은 스프레드 시트의 값 목록입니다. 이 목록에는 형식 지정 데이터가 포함되지 않고 셀의 값만 포함됩니다.
누군가 파이썬에서 셀 값, 배경색, 정렬 및 기타 셀 서식 정보를 스프레드 시트(). values () 또는 스프레드 시트에서 가져올 수 있습니까?