Search code examples
objective-coptimizationgdata-api

How to send a cell (or records) range query to fetch a ranged feed from worksheet entry from iPhone app to Google Spreadsheet?


I'm trying to find how to get a specified with range feed of cells (or records) from a worksheet entry.

I found that, there is a solution for that in "Google Data APIs .NET client library"

and in "Google Data API Python client library"

But can't find how to do it with objective-c. Is it possible? If yes, then how? If not, then how to implement this opportunity & how hard is it to do? The reason i'm intrested is desire to reduce traffic among iPhone app & Google.

Thanks in advance.


Solution

  • I've found the answer myself while investigated Gdata-objectivec-client headers. So the solution is to make a GDataQuerySpreadsheet to worksheet with entry with pre-set number of properties: minimumRow, maximumRow, minimumColumn, maximumColumn. It is also possible to use simply - (void)setRange:(NSString *)str;

    Here's a code example:

    - (void) fetchWorksheet: (GDataEntryWorksheet*) worksheet {
        NSURL *cellsFeedURL = [[worksheet cellsLink] URL];
        if (cellsFeedURL) {
            GDataServiceTicket *ticket;
            GDataQuerySpreadsheet *query = [GDataQuerySpreadsheet spreadsheetQueryWithFeedURL: cellsFeedURL];
            [query setMinimumRow: 0];
            [query setMaximumRow: 2];
            [query setMinimumColumn: 0];
            [query setMaximumColumn: 2];
            [query setTitleQuery: @"myQuery"];
    
            ticket = [mService fetchFeedWithQuery:query
                                         delegate:self
                                didFinishSelector:@selector(fetchFeedOfCellsTicket:
                                                            finishedWithFeed:
                                                            error:)];
        }    
    }
    

    The only disadvantage of this is that resulting feed contains cells, but not records. And cells are considered deprecated (i've heard it). It would be better to fetch a table with records, and not worksheet with cells. But GData-objectivec-client doesn't support it, unfortunately.

    But it works. I've checked.