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

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

问题描述

我正在尝试编写一个将其数据库存储在Google电子表格中的iPhone应用程序。我遵循DrEdit示例此处,它使用Drive API将纯文本文件读取/写入Google云端硬盘。我试图修改示例应用程序来使用电子表格。我能够上传一个CSV文件并要求Google将其转换。不过,我真正想要的是直接使用mimeType:application / vnd.google-apps.spreadsheet。我对此很新,如果有人能指点我一个例子,这将非常有帮助。对于初学者,我想实现类似以下内容:

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

NSString * data = @cell1,cell2,cell3;

NSData * spreadSheetContent = nil;

/ *
如何用数据初始化spreadSheetContent?
* /

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

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

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

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



提前致谢! 您应该使用Google电子表格API直接操纵电子表格的单元格:



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



Google数据API支持Spreadsheet API Objective- C客户端库,其中还包括一些可用作参考的示例: -client /rel =noreferrer> http://code.google.com/p/gdata-objectivec-client/


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];
}

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?

Thanks in advance!

解决方案

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

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

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天全站免登陆