mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-25 14:56:04 +03:00
Feature: Additional row iterator options: allow a start row to be defined in the constructor; seek(), and prev() methods added.
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@84512 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
b235c531a7
commit
24bd9b5e8a
@ -19,10 +19,10 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Worksheet
|
||||
* @package PHPExcel_Worksheet
|
||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
* Used to iterate rows in a PHPExcel_Worksheet
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Worksheet
|
||||
* @package PHPExcel_Worksheet
|
||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Worksheet_RowIterator extends CachingIterator
|
||||
@ -51,14 +51,24 @@ class PHPExcel_Worksheet_RowIterator extends CachingIterator
|
||||
*/
|
||||
private $_position = 1;
|
||||
|
||||
/**
|
||||
* Start position
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_startRow = 1;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new row iterator
|
||||
*
|
||||
* @param PHPExcel_Worksheet $subject
|
||||
* @param PHPExcel_Worksheet $subject The worksheet to iterate over
|
||||
* @param integer $startRow The row number at which to start iterating
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $subject = null) {
|
||||
public function __construct(PHPExcel_Worksheet $subject = null, $startRow = 1) {
|
||||
// Set subject
|
||||
$this->_subject = $subject;
|
||||
$this->resetStart($startRow);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,43 +79,70 @@ class PHPExcel_Worksheet_RowIterator extends CachingIterator
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewind iterator
|
||||
* (Re)Set the start row and the current row pointer
|
||||
*
|
||||
* @param integer $startRow The row number at which to start iterating
|
||||
*/
|
||||
public function rewind() {
|
||||
$this->_position = 1;
|
||||
}
|
||||
public function resetStart($startRow = 1) {
|
||||
$this->_startRow = $startRow;
|
||||
$this->seek($startRow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Current PHPExcel_Worksheet_Row
|
||||
*
|
||||
* @return PHPExcel_Worksheet_Row
|
||||
*/
|
||||
public function current() {
|
||||
return new PHPExcel_Worksheet_Row($this->_subject, $this->_position);
|
||||
}
|
||||
/**
|
||||
* Set the row pointer to the selected row
|
||||
*
|
||||
* @param integer $row The row number to set the current pointer at
|
||||
*/
|
||||
public function seek($row = 1) {
|
||||
$this->_position = $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Current key
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function key() {
|
||||
return $this->_position;
|
||||
}
|
||||
/**
|
||||
* Rewind the iterator to the starting row
|
||||
*/
|
||||
public function rewind() {
|
||||
$this->_position = $this->_startRow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Next value
|
||||
*/
|
||||
public function next() {
|
||||
++$this->_position;
|
||||
}
|
||||
/**
|
||||
* Return the current row in this worksheet
|
||||
*
|
||||
* @return PHPExcel_Worksheet_Row
|
||||
*/
|
||||
public function current() {
|
||||
return new PHPExcel_Worksheet_Row($this->_subject, $this->_position);
|
||||
}
|
||||
|
||||
/**
|
||||
* More PHPExcel_Worksheet_Row instances available?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function valid() {
|
||||
return $this->_position <= $this->_subject->getHighestRow();
|
||||
}
|
||||
/**
|
||||
* Return the current iterator key
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function key() {
|
||||
return $this->_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the iterator to its next value
|
||||
*/
|
||||
public function next() {
|
||||
++$this->_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the iterator to its previous value
|
||||
*/
|
||||
public function prev() {
|
||||
if ($this->_position > 1)
|
||||
--$this->_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate if more rows exist in the worksheet
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function valid() {
|
||||
return $this->_position <= $this->_subject->getHighestRow();
|
||||
}
|
||||
}
|
||||
|
@ -321,6 +321,7 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
|
||||
foreach ($this->_phpExcel->getAllSheets() as $sheet) {
|
||||
if (count($sheet->getDrawingCollection()) > 0) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
Fixed in SVN:
|
||||
- Feature: (MBaker) Options for cell caching using Igbinary and SQLite/SQlite3.
|
||||
- Feature: (MBaker) Additional row iterator options: allow a start row to be defined in the constructor; seek(), and prev() methods added.
|
||||
- General: (MBaker) Fix to build to ensure that Examples are included with the documentation
|
||||
- General: (MBaker) Reduce cell caching overhead using dirty flag to ensure that cells are only rewritten to the cache if they have actually been changed
|
||||
- General: (MBaker) Improved memory usage in CSV Writer
|
||||
|
Loading…
Reference in New Issue
Block a user