使用Zend GData,如何通过查找其值来获取工作表单元格索引? [英] Using Zend GData, How do i get a worksheet cell index by looking for its value?
本文介绍了使用Zend GData,如何通过查找其值来获取工作表单元格索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我在工作表中有一个单元格,其值为最后一个数据单元格" 这是使用Zend GData获取此单元格(即A5)索引的正确方法吗?
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;
我想稍后将$ 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);
,但索引值为数字.如何将其转换为"A1"格式? 谢谢
but the index value is numeric. how do i convert it to the "A1" format ? thanks
推荐答案
您可以这样获得单元格ID:
You can get the cell ID like this:
$cellId = $row . $col; //vars from your code above.
echo $cellId;
如果$ col为'A'并且$ row为1,则将输出
If $col is 'A' and $row is 1 this will output
A1
这篇关于使用Zend GData,如何通过查找其值来获取工作表单元格索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文