简体   繁体   English

如何在 Gsheet 的第二行插入数据?

[英]How to insert data in the second row of a Gsheet?

I'm inserting data into a Google Spreadsheet with this code:我正在使用以下代码将数据插入 Google 电子表格:

sheet_instance.insert_rows(my_data)

But it always inserts into the first row, where it has some important formulas.但它总是插入第一行,那里有一些重要的公式。 Is it possible to keep the first row of the spreadsheet untouched and insert the data starting at the second row, with gspread library?是否可以使用 gspread 库保持电子表格的第一行不变并从第二行开始插入数据?

You can use values_update您可以使用values_update

sheet_instance.values_update(
    'Sheet1!A2',
    params={
        'valueInputOption': 'USER_ENTERED'
    },
    body={
        'values': [[1, 2, 3]]
    }
)

append_rows might be a good alternative too (you just need to specify table_range ) append_rows也可能是一个不错的选择(您只需要指定table_range

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

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