Using Zend GData, How do i get a worksheet cell in

2019-08-23 04:50发布

suppose i have a cell in a worksheet that has a value of "last data cell" is this the correct way to get the index of this cell (i.e A5) using Zend GData ?

    $query = new Zend_Gdata_Spreadsheets_CellQuery();
$query->setSpreadsheetKey($this->_spreadsheetKey);
$query->setWorksheetId($worksheet);

$cellFeed = $this->_spreadsheetService->getCellFeed($query);

foreach($cellFeed as $cellEntry) {
      $row = $cellEntry->getCell()->getRow();
      $col = $cellEntry->getCell()->getColumn();
      $val = $cellEntry->getCell()->getText();
      if ($val == 'last data cell'){ $index = array($row, $col); }
      //echo "$row, $col = $val\n";
}
return  $index;

i want to use the $index value later as a boundaries to define a range, like this for example:

$range = (string)$index[0]+1 + $index[1].":F20";
$contentAsCells = $worksheet->getContentsAsCells($range);

but the index value is numeric. how do i convert it to the "A1" format ? thanks

1条回答
啃猪蹄的小仙女
2楼-- · 2019-08-23 05:26

You can get the cell ID like this:

$cellId = $row . $col; //vars from your code above.
echo $cellId;

If $col is 'A' and $row is 1 this will output

A1

查看更多
登录 后发表回答