Note that there are some explanatory texts on larger screens.

plurals
  1. POInsert new cell in google spreadsheet using GData API in iOS
    text
    copied!<p>After finally figuring out how to pull data from google spreadsheets, I can't understand how to add new entries to the end of file. </p> <p>Here's what I want to achieve: My app should send some survey results to a google spreadsheet, here's how the file is supposed to look: </p> <p><img src="https://i.stack.imgur.com/s2SS1.png" alt="enter image description here"></p> <p>Let's assume that I need to send the next survey results to that spreadsheet. How do I send them and make sure that they appear just under the last survey results? </p> <p>Thanks</p> <p><strong>UPDATE</strong></p> <p>I've found an answer long ago, so decided to update the question for lone rangers like me that couldn't find any info on this topic :)</p> <p>For this answer I assume that you already know how to get to the spreadsheet's cells feed.</p> <p>Here's what you need to do after you get the cells feed: </p> <ol> <li><p>First of all we need to find out the last row number so we can later on write to the row under it. </p> <pre><code>NSArray * entries = [cellsFeed entries]; // we pull out all the entries from the feed GDataEntrySpreadsheetCell * lastCell = [entries lastObject]; // then we take just the last one NSString * title = [[lastCell title] stringValue]; // then we need it's title. The cells title is a combination of the column letter and row number (ex: A20 or B5) NSString * lastRow = [[title componentsSeparatedByCharactersInSet: [[NSCharacterSet decimalDigitCharacterSet] invertedSet]] componentsJoinedByString:@""]; // then we remove the letters and we're left only with the row number </code></pre></li> <li><p>We can now send some data to the row under the last row like this: </p> <pre><code> // create a cell object and give it the row number (in our case it's the row under lastRow, so we add + 1), column number (yes, here you should provide a number and not a letter) and the string that you want to appear in the cell GDataSpreadsheetCell * cell = [GDataSpreadsheetCell cellWithRow:[lastRow intValue] + 1 column:1 inputString:@"some value" numericValue:nil resultString:nil]; // create a cellEntry object that will contain the cell GDataEntrySpreadsheetCell * cellEntry = [GDataEntrySpreadsheetCell spreadsheetCellEntryWithCell:cell]; // upload the cellEntry to your spreadsheet [_srv fetchEntryByInsertingEntry:cellEntry forFeedURL: [[workSheet cellsLink] URL] // make sure that you save the workSheet feed in an instance variable so that you'll be able to reach it in another method. If you pulled data from the spreadsheet that you must already know how to get the worksheet feed delegate:self didFinishSelector:nil]; </code></pre></li> </ol> <p>That's it! The data should upload to your spreadsheet. </p> <p>Let me know if you have any questions, I know the documentation is kinda scarce for this.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload