ios - 如何在 iOS 上使用 Google Drive API 处理电子表格

标签 ios google-drive-api gdata-api google-spreadsheet-api

我正在尝试编写一个将其数据库存储在 Google 电子表格中的 iPhone 应用程序。我遵循了 DrEdit 示例 here它使用 Drive API 将纯文本文件读/写到 Google Drive。我正在尝试修改示例应用程序以改为使用电子表格。我能够上传一个 csv 文件并要求谷歌转换它。但是,我真正想要的是直接使用 mimeType:“application/vnd.google-apps.spreadsheet”。我对此很陌生,如果有人能给我举个例子,那将非常有帮助。对于初学者,我想实现如下目标

- (void)uploadSpreadSheetWithThreeCells {
GTLUploadParameters *uploadParameters = nil;

NSString *data = @"cell1,cell2,cell3";

NSData *spreadSheetContent = nil;

/* 
  How to initialize spreadSheetContent with data? 
*/

[GTLUploadParameters uploadParametersWithData:spreadSheetContent
      MIMEType:@"application/vnd.google-apps.spreadsheet"];

GTLQueryDrive *query = [GTLQueryDrive queryForFilesInsertWithObject:self.driveFile
                                        uploadParameters:uploadParameters];

[self.driveService executeQuery:query completionHandler:nil];
}

此外,Google Drive API 是否适合使用?最终,我希望能够更新电子表格的选定单元格,而不是上传整个文档。我找到了一些其他选项,例如 gdata api 和电子表格 api,但 Drive API 似乎是最新的,它应该包含其他两个的功能?

提前致谢!

最佳答案

您应该使用 Google Spreadsheets API 直接操作电子表格的单元格:

https://developers.google.com/google-apps/spreadsheets/

Google Data APIs Objective-C Client Library 支持 Spreadsheet API,其中还包含一些示例,您可以将其用作引用:

http://code.google.com/p/gdata-objectivec-client/

关于ios - 如何在 iOS 上使用 Google Drive API 处理电子表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13211682/

相关文章:

google-drive-api - 接收访问 token 谷歌驱动器API,C#

google-sheets - 在下拉列表中选择项目时其他工作表上的引用值

java - Google Drive SDK File.getFileSize() NullPointerException

iphone - 求一个使用GData API解析xml和获取属性的示例代码

ios - UIEvent 和 UIEventTypeMotion 仅拦截摇动手势吗?

iphone - 从横向切换到纵向后,将 UIScrollView 保持在正确的位置

ios - JSON 文件中有 É。当我从服务器上的提要下载时,无法解析返回的数据。项目中本地副本中的相同数据可以下载吗?

javascript - 解析云代码两次发送推送通知

Java GData Spreadsheets API 获取 Feed 失败

c# - 使用 GData API 将事件添加到 "specific"Google 日历