12

我正在尝试编写一个将其数据库存储在 Google 电子表格中的 iPhone 应用程序。我在这里遵循 DrEdit 示例,它使用 Drive API 将纯文本文件读/写到 Google Drive。我正在尝试修改示例应用程序以使用电子表格。我能够上传一个 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];
}

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

提前致谢!

4

1 回答 1

9

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

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

电子表格 API 由 Google Data APIs Objective-C 客户端库支持,其中还包括一些示例,您可以将其用作参考:

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

于 2012-11-03T19:08:01.683 回答