Using Zend GData, How do i get a worksheet cell index by looking for its value?

两盒软妹~` 提交于 2019-12-11 19:32:20

问题


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:


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



来源:https://stackoverflow.com/questions/11089041/using-zend-gdata-how-do-i-get-a-worksheet-cell-index-by-looking-for-its-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!