问题描述
我正在使用Google电子表格API v4.我想通过python脚本删除一些行.我尝试了他们的示例代码,但出现以下错误
I am using Google spreadsheets API v4. I want to delete some rows via python script. i tried their example code and i got the following error
我的代码:
batch_update_spreadsheet_request_body = {
"requests": [
{
"deleteDimension": {
"range": {
"sheetId": sheetId,
"dimension": "ROWS",
"startIndex": 0,
"endIndex": 3
}
}
},
{
"deleteDimension": {
"range": {
"sheetId": sheetId,
"dimension": "COLUMNS",
"startIndex": 1,
"endIndex": 4
}
}
},
],
}
request = sheets_service.spreadsheets().batchUpdate(spreadsheetId=sheetId, body=batch_update_spreadsheet_request_body)
response = request.execute()
完整追溯
推荐答案
在您的脚本中,sheetId
用于"sheetId": sheetId,
和spreadsheetId=sheetId
.
In your script, sheetId
is used for "sheetId": sheetId,
and spreadsheetId=sheetId
.
-
sheetId
是URL的gid
.请在这里检查. https://developers.google.com/sheets/api/guides/concepts#sheet_id
"sheetId": sheetId,
处的sheetId
at"sheetId": sheetId,
isgid
of URL. Please check here. https://developers.google.com/sheets/api/guides/concepts#sheet_id
sheetId
是电子表格ID.请在这里检查. https://developers.google.com/sheets/api/guides/concepts#spreadsheet_id
sheetId
at spreadsheetId=sheetId
is Spreadsheet ID. Please check here. https://developers.google.com/sheets/api/guides/concepts#spreadsheet_id
每个sheetId
是不同的.因此,请对其进行修改.
Each sheetId
is different. So please modify them.
这篇关于'requests [0] .delete_dimension.range.sheet_id'(TYPE_INT32)处的值无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!