gpt4 book ai didi

ios - 如何使用 Sheets API v4 在 Swift 4 中创建新的 Google 表格

转载 作者:搜寻专家 更新时间:2023-10-31 21:46:14 27 4
gpt4 key购买 nike

我不知道如何使用 Sheets API 在 Swift 4 中创建新的 Google 表格。我还希望稍后在我的代码中使用相同的 Google 工作表,因此我需要它返回电子表格 ID 的值。这是我目前所拥有的。

func createNewSheet() {

let url = NSURL(string: "https://sheets.googleapis.com/v4/spreadsheets")

let task = URLSession.shared.dataTask(with: url! as URL) {
(data, response, error) in
print(NSString(data: data!, encoding: String.Encoding.utf8.rawValue)!)
}
task.resume()
print (task)
}

最佳答案

有一个 Add a Sheet guide来自文档:

The following spreadsheets.batchUpdate request adds a sheet to a spreadsheet, while also setting the title, size, and tab color. This request returns an AddSheetResponse, consisting of an object with the created sheet's properties (such as its sheetId).

The request protocol is shown below. The Updating Spreadsheets guide shows how to implement a batch update in different languages using the Google API client libraries.

POST https://sheets.googleapis.com/v4/spreadsheets/spreadsheetId:batchUpdate
{
"requests": [
{
"addSheet": {
"properties": {
"title": "Deposits",
"gridProperties": {
"rowCount": 20,
"columnCount": 12
},
"tabColor": {
"red": 1.0,
"green": 0.3,
"blue": 0.4
}
}
}
}
]
}

关于ios - 如何使用 Sheets API v4 在 Swift 4 中创建新的 Google 表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50144782/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com