简体   繁体   English

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

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

I'm searching through the documentation as best I can, I'm just on a time limit here so if someone can tell me that would be great.我正在尽我所能搜索文档,我只是在这里有时间限制,所以如果有人能告诉我那会很棒。

I need to insert data into a column and have it push the data in the column down when it's inserted.我需要将数据插入一列,并让它在插入时将列中的数据向下推。 For example I need to add the word "Good" at the top of the column, "Bad" WAS at the top, but when I pushed in "Good", "Bad" became the number two spot, the number two spot became the number three spot, etc. It needs to do this without deleting or moving the rows themselves because I'm reading data from two columns in the sheet and then writing to a third column.例如我需要在栏的顶部添加单词“Good”,顶部是“Bad”,但是当我推入“Good”时,“Bad”变成了第二个位置,第二个位置变成了第三点等。它需要在不删除或移动行本身的情况下执行此操作,因为我正在从工作表中的两列读取数据,然后写入第三列。

Thanks in advance!提前致谢!

Welcome to StackOverflow.欢迎来到 StackOverflow。

From what I understood reading your question is that you have already been able to read data from two column and now you just want to store some of them in a separate column.据我了解阅读您的问题是,您已经能够从两列中读取数据,现在您只想将其中一些存储在单独的列中。 Apologies if I misunderstood your question.如果我误解了你的问题,我深表歉意。

If I understood your question right, I would suggest you to create a list of the requests and make a batch update of it.如果我正确理解您的问题,我建议您创建一个请求列表并对其进行批量更新。 Which would help you refraining yourself from reaching the write quota.这将帮助您避免达到写入配额。

So, here how it goes-所以,这是怎么回事-

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})

This will update the cells with your given value.这将使用您的给定值更新单元格。 For detailed information and other formatting follow the documentation .有关详细信息和其他格式,请遵循文档

暂无
暂无

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

相关问题 如何使用Google Apps脚本合并Google表格中的列值 - How do I Merge Column Values in Google Sheets with Google Apps Script 如何获取数组中列的值并在其中搜索值? (Google 表格的 Apps 脚本) - How do I get values of a column in an array and search for a value in it? (Google Sheets' Apps Script) 我如何更改此 google 应用程序脚本以根据列日期隐藏工作表列而不是行 - how do I change this google app script to hide sheets columns instead of rows based on column dates 如何在 Google Sheets App Script 中复制过滤范围的值和背景颜色? - How do I copy both the values and background color of a filtered range in Google Sheets App Script? 如何在 Google 表格中的所有表格(选项卡)上运行 Google 表格应用脚本? - How do I run Google Sheets App Script on all sheets (tabs) in a Google Sheet? 如何使用 Google Script 从 Google 表格中提取特定列? - How do I extract a specific Column from google sheets using Google Script? 如何在 Google 表格中编写脚本以删除列中的某些值? - How do you make a script in Google Sheets to delete certain values in a column? 如何使用Google表格脚本有效地将值和公式的范围从一列移动到另一列? - How can I effeciently move a range of values and formulas from one column to another using a google sheets script? 如何使用应用程序脚本 [GOOGLE SHEETS] 找到一列数字中的第一个“0” - How to find the first '0' in a column of numbers using app script [GOOGLE SHEETS] Google 表格应用脚本:如何在下拉值更改时发送 email? - Google Sheets app script : How to send email on change in dropdown values?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM