本文介绍了'requests [0] .delete_dimension.range.sheet_id'(TYPE_INT32)处的值无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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": sheetId,处的
  1. sheetId是URL的gid.请在这里检查. https://developers.google.com/sheets/api/guides/concepts#sheet_id

  1. sheetId at "sheetId": sheetId, is gid 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)处的值无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 07:29