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

mlp*_*lpg 11 gdata-api ios google-spreadsheet-api google-drive-api

我正在尝试编写一个将其数据库存储在Google电子表格中的iPhone应用程序.我按照此处的DrEdit示例使用Drive API将纯文本文件读/写到Google云端硬盘.我正在尝试修改示例应用以使用电子表格.我能够上传csv文件并要求Google进行转换.但是,我真正想要的是直接使用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];
}
Run Code Online (Sandbox Code Playgroud)

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

提前致谢!

Cla*_*ino 9

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

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

Google Data API Objective-C客户端库支持Spreadsheet API,其中还包含一些可用作参考的示例:

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