13

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!

Claudio Cherubino
  • 14,896
  • 1
  • 35
  • 42
mlpg
  • 133
  • 1
  • 1
  • 5
  • have you able to update a google drive spreadsheet ? could you update your code. I have de same problem, update 3 fields of a very simple google public table. – doxsi Feb 10 '14 at 17:21

1 Answers1

10

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/

Claudio Cherubino
  • 14,896
  • 1
  • 35
  • 42
  • Am facing service authentication issue in to fetch spreadsheets.in xcode 5 its working fine.But currently am using xcode 8 in this am facing service authentication issue @priya could you guide me in this please – sandy Jul 11 '17 at 07:03
  • @sandy.... u can follow the above steps it will get resolve...or else post your error here – Priya Jul 19 '17 at 10:20
  • 'OIDRegistrationRequest.h' file not found. This issue is facing.i checked that file located in project structure.I followed this link also no https://github.com/google/google-api-objectivec-client-for-rest/issues/108 but no use @Priya – sandy Aug 02 '17 at 07:06
  • Here is the new link for the Google Sheet API https://developers.google.com/sheets/api/guides/concept – itMaxence Mar 01 '23 at 13:21