繁体   English   中英

如何将值推送到列 Google Sheets App Script

[英]How do I push values into a column Google Sheets App Script

我正在尽我所能搜索文档,我只是在这里有时间限制,所以如果有人能告诉我那会很棒。

我需要将数据插入一列,并让它在插入时将列中的数据向下推。 例如我需要在栏的顶部添加单词“Good”,顶部是“Bad”,但是当我推入“Good”时,“Bad”变成了第二个位置,第二个位置变成了第三点等。它需要在不删除或移动行本身的情况下执行此操作,因为我正在从工作表中的两列读取数据,然后写入第三列。

提前致谢!

欢迎来到 StackOverflow。

据我了解阅读您的问题是,您已经能够从两列中读取数据,现在您只想将其中一些存储在单独的列中。 如果我误解了你的问题,我深表歉意。

如果我正确理解您的问题,我建议您创建一个请求列表并对其进行批量更新。 这将帮助您避免达到写入配额。

所以,这是怎么回事-

request = []
request.append({
      "updateCells": {
           "rows": [
               {
                  "values":[
                     {
                        "userEnteredValue": {
                           "numberValue": 546564      #Assuming your value is integer
                        },
                        "userEnteredFormat": {
                           "horizontalAlignment": "CENTER",
                           "verticalAlignment": "MIDDLE"
                        }
                     }
                  ]
               }
            ],
           "fields": "*",
           "range": {
                #Replace these values with actual values
                "sheetId": sheetId,
                "startRowIndex": startRow,    #Indexing start from 0
                "endRowIndex": endRow,
                "startColumnIndex": startColumn,
                "endColumnIndex": endColumn,
            }
      }
   })
#You can add more requests like this in the list and then execute
body = {
    "requests": request
}
response = sheet.spreadsheets().batchUpdate(
    spreadsheetId=spreadsheet_id,
    body=body).execute()
#If you are using gspread, then you can use this
sheet.batch_update({"requests" : request})

这将使用您的给定值更新单元格。 有关详细信息和其他格式,请遵循文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM