ios - 在文件夹 swift iOS 中创建 Google 电子表格

标签 ios swift google-api google-sheets-api

我正在尝试使用 google drive/sheets api 在特定文件夹中创建 google 电子表格。

到目前为止,我的代码在谷歌驱动器的根目录中创建了一个电子表格。

let newSheet = GTLRSheets_Spreadsheet.init()
let properties = GTLRSheets_SpreadsheetProperties.init()

properties.title = name
newSheet.properties = properties

let query = GTLRSheetsQuery_SpreadsheetsCreate.query(withObject:newSheet)
query.fields = "spreadsheetId"

query.completionBlock = { (ticket, result, NSError) in

    if let error = NSError {

    }
    else {
        let response = result as! GTLRSheets_Spreadsheet
        let identifier = response.spreadsheetId
        completion!(true,nil,identifier)
    }
}
service.executeQuery(query, completionHandler: nil)

我在查询或 GTLRSheets 上看不到任何属性来设置父文件夹或 url。任何帮助都会很棒。谢谢

最佳答案

您可以使用继承的JSONString 方法获取JSON 字符串并保存。

let JSON = newSheet.JSONString()
JSON.write(toFile:…,automically:…, encoding:…) // or whatever method to write

关于ios - 在文件夹 swift iOS 中创建 Google 电子表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45707584/

相关文章:

ios - 'NSInternalInconsistencyException',原因 : 'Unrecognized database version: ' Firebase crash on physical device

swift - 在以编程方式创建的 UITextView 上捕获 UITapGesture

ios - 检查 Array 中的 Int 。 swift 3,iOS

ios - UserDefaults 编码失败

oauth-2.0 - 对于 Google+ API 和 OAuth 关闭,我需要更改哪些内容?

ios - 如何在 IOS 中使用 IDTECH 刷卡器读取信用卡信息?

ios - 无法在 Swift 4 中解码日期

iphone - 开发像 webapp.to 这样的移动应用程序

java.io.FileNotFoundException :/key. p12:打开失败:ENOENT(没有这样的文件或目录)

c# - 如何使用 JSON.NET 解析带有十六进制编码字符的格式错误的 JSONP?