I am working with relatively large spreadsheets from gdocs and access them via the zend library. I only need certain columns at any given time so in order to save memory it would be helpful to use the list-based feed to only retrieve these certain columns and not the whole spreadsheet. The basic query I am using is according to the zend documentation
$query = new Zend_Gdata_Spreadsheets_ListQuery();
$query->setSpreadsheetKey($spreadsheetKey);
$query->setWorksheetId($worksheetId);
$listFeed = $spreadsheetService->getListFeed($query);
I have the opportunity to send a structured query via $query->setSpreadsheetQuery('name=someName');
but as far as I can see this only works for limiting the number of rows returned and not the number of columns. Is there a way to somehow use this to get specific columns? Alternatively it would be helpful to get only certain, previously specified rows of the spreadsheet so as to retrieve only blocks of the spreadsheet and thin out one block at the time. Either way, I need to avoid having the whole spreadsheet in the memory at any given time.
Thanks for any help.
I managed to work around this problem using a cell-based feed. Basically what I did was to first get the column number for a specific column header like so
which will give me the column number for the
$column
column. I would then proceed to get a specific range of rows for the given column number so that I can read in the whole column block by block without ever having the whole spreadsheet(or column) in memory. This can be done asby changing
$startingRow
and$endingRow
I can iterate through the column. One has to be careful with the choice of these though, since if they are 'out of bounds' the google api will return a http 400 code. The cells don't have to have value in them, but they have to exist(scroll down your spreadsheet and the last row number you see should be your maximum for both values). I think per default a spreadsheet with 100(empty) rows is created.This is probably not the most elegant or fastest solution, but it works for me.