Google Sheet API附加到特定工作表 [英] Google Sheet API append to a specific sheet
问题描述
根据 API 似乎我无法指定工作表添加数据的位置。它将所有内容都添加到第一张表格中。是否真的是这样?
因为我可以用多张纸创建一个文件,但是我不能在第二张纸上书写?
$ b $如果您只是想在工作表上书写,请按照 /写作rel =nofollow noreferrer>基本写作表指南。您可以使用PUT方法在工作表上书写:
PUT https://sheets.googleapis.com/v4/spreadsheets / spreadsheetId /值/ Sheet 1中!A1:?D5 valueInputOption = USER_ENTERED
和指定表的名称和单元格范围为:
{
范围:Sheet1!A1:D5,
majorDimension:ROWS,
values:[
[Item,Cost,Stocked,Ship Date],
[Wheel $ 20.50,4,3/1/2016],
[Door,$ 15,2,3/15/2016],
[发动机 ,$ 100,1,30/20/2016],
[汇总,= SUM(B2:B4),= SUM(C2:C4),= MAX (D2:D4)]
],
}
关于您的 spreadsheets.values.append
问题,我相信您已经阅读过文档必须说明的内容:
< blockquote>
将值附加到电子表格。输入范围用于搜索现有数据的
并在该范围内找到一个表。价值将是
追加到表的下一行,从表的第一列
开始。
这仅用于在表格的最后一行添加。
according to the API it seems that I can't specify the sheet where to append the data. It appends everything in the first sheet. Is it really like this?
Beacuse I can create a file with multiple sheets, but then I can't write on the second sheet?
If you simply want to write on a sheet, follow the Basic Writing Sheets guide. You can write on a sheet by using a PUT method:
PUT https://sheets.googleapis.com/v4/spreadsheets/spreadsheetId/values/Sheet1!A1:D5?valueInputOption=USER_ENTERED
and specify the name of sheet and cell range in like:
{
"range": "Sheet1!A1:D5",
"majorDimension": "ROWS",
"values": [
["Item", "Cost", "Stocked", "Ship Date"],
["Wheel", "$20.50", "4", "3/1/2016"],
["Door", "$15", "2", "3/15/2016"],
["Engine", "$100", "1", "30/20/2016"],
["Totals", "=SUM(B2:B4)", "=SUM(C2:C4)", "=MAX(D2:D4)"]
],
}
With regard to your spreadsheets.values.append
question, I'm sure you've already read what the docs had to say:
Appends values to a spreadsheet. The input range is used to search for existing data and find a "table" within that range. Values will be appended to the next row of the table, starting with the first column of the table.
This is only for adding at the last row of the table.
这篇关于Google Sheet API附加到特定工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!