如何在 iOS 上使用 Google Drive API 处理电子表格 [英] how to work with spreadsheets using Google Drive API on iOS

查看:13
本文介绍了如何在 iOS 上使用 Google Drive API 处理电子表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to write an iPhone app that stores its database in a Google spreadsheet. I followed the DrEdit example here which uses the Drive API to read/write plain text files to Google Drive. I'm trying to modify the example app to work with spreadsheets instead. I was able to upload a csv file and ask Google to convert it. However, what I really want is to directly work with mimeType: "application/vnd.google-apps.spreadsheet". I'm very new at this and it would be extremely helpful if someone could point me to an example. For starters, I'd like to achieve something like the following

- (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 是最新的,它应该包含其他两个的功能?

Also, is Google Drive API the right thing to use? Ultimately, I want to have the ability to update selected cells of a spreadsheet instead of uploading an entire document. I found some other options such as the gdata api and spreadsheet api, but it seems that Drive API is the newest and it's supposed to contain the functionalities of the other two?

提前致谢!

推荐答案

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

You should use the Google Spreadsheets API to directly manipulate the cells of a spreadsheet:

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

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

The Spreadsheet API is supported by the Google Data APIs Objective-C Client Library which also includes some samples that you can use as reference:

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

这篇关于如何在 iOS 上使用 Google Drive API 处理电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆