我正在尝试编写一个将其数据库存储在 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,其中还包含一些示例,您可以将其用作引用:
关于ios - 如何在 iOS 上使用 Google Drive API 处理电子表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13211682/