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
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Worksheet
|
* @package PHPExcel_Worksheet
|
||||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
* Used to iterate rows in a PHPExcel_Worksheet
|
* Used to iterate rows in a PHPExcel_Worksheet
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Worksheet
|
* @package PHPExcel_Worksheet
|
||||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class PHPExcel_Worksheet_RowIterator extends CachingIterator
|
class PHPExcel_Worksheet_RowIterator extends CachingIterator
|
||||||
|
@ -51,14 +51,24 @@ class PHPExcel_Worksheet_RowIterator extends CachingIterator
|
||||||
*/
|
*/
|
||||||
private $_position = 1;
|
private $_position = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start position
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $_startRow = 1;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new row iterator
|
* 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
|
// Set subject
|
||||||
$this->_subject = $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() {
|
public function resetStart($startRow = 1) {
|
||||||
$this->_position = 1;
|
$this->_startRow = $startRow;
|
||||||
}
|
$this->seek($startRow);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current PHPExcel_Worksheet_Row
|
* Set the row pointer to the selected row
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Worksheet_Row
|
* @param integer $row The row number to set the current pointer at
|
||||||
*/
|
*/
|
||||||
public function current() {
|
public function seek($row = 1) {
|
||||||
return new PHPExcel_Worksheet_Row($this->_subject, $this->_position);
|
$this->_position = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current key
|
* Rewind the iterator to the starting row
|
||||||
*
|
*/
|
||||||
* @return int
|
public function rewind() {
|
||||||
*/
|
$this->_position = $this->_startRow;
|
||||||
public function key() {
|
}
|
||||||
return $this->_position;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Next value
|
* Return the current row in this worksheet
|
||||||
*/
|
*
|
||||||
public function next() {
|
* @return PHPExcel_Worksheet_Row
|
||||||
++$this->_position;
|
*/
|
||||||
}
|
public function current() {
|
||||||
|
return new PHPExcel_Worksheet_Row($this->_subject, $this->_position);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* More PHPExcel_Worksheet_Row instances available?
|
* Return the current iterator key
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function valid() {
|
public function key() {
|
||||||
return $this->_position <= $this->_subject->getHighestRow();
|
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) {
|
foreach ($this->_phpExcel->getAllSheets() as $sheet) {
|
||||||
if (count($sheet->getDrawingCollection()) > 0) {
|
if (count($sheet->getDrawingCollection()) > 0) {
|
||||||
$found = true;
|
$found = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
Fixed in SVN:
|
Fixed in SVN:
|
||||||
- Feature: (MBaker) Options for cell caching using Igbinary and SQLite/SQlite3.
|
- 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) 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) 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
|
- General: (MBaker) Improved memory usage in CSV Writer
|
||||||
|
|
Loading…
Reference in New Issue