是否有一种更有效的方法来删除循环中的行而不是此解决方法?
/**
* Delete all rows that are identified on the 'D'
* column with a $tag String value
* @param String $tag
*/
protected function deleteRowsByTag( $tag )
{
$found = true;
while( $found )
{
$found = false;
foreach ( $this->objWorksheet->getRowIterator() as $row )
{
$cell = $this->objWorksheet->getCell( "D" . $row->getRowIndex() );
$tag = str_replace( "tag_delete_", "", $tag );
if ( strtolower( trim( $cell->getValue() ) ) === $tag )
{
$delete_row = $row->getRowIndex();
// $this->objWorksheet->getRowIterator()->seek( $delete_row-2 );
$this->objWorksheet->removeRow( $delete_row );
$found = true;
break;
}
}
}
} // deleteRowByTag
我尝试将行迭代器设置为prev-> prev位置,但这没有做到这一点(我的一次尝试在代码中被注释)
由于
PS:@Mark Baker - 对不起,我没有太广泛地阅读手册:)