ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ColumnIterator.php
Go to the documentation of this file.
1<?php
39{
45 private $_subject;
46
52 private $_position = 0;
53
59 private $_startColumn = 0;
60
61
67 private $_endColumn = 0;
68
69
77 public function __construct(PHPExcel_Worksheet $subject = null, $startColumn = 'A', $endColumn = null) {
78 // Set subject
79 $this->_subject = $subject;
80 $this->resetEnd($endColumn);
81 $this->resetStart($startColumn);
82 }
83
87 public function __destruct() {
88 unset($this->_subject);
89 }
90
97 public function resetStart($startColumn = 'A') {
98 $startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1;
99 $this->_startColumn = $startColumnIndex;
100 $this->seek($startColumn);
101
102 return $this;
103 }
104
111 public function resetEnd($endColumn = null) {
112 $endColumn = ($endColumn) ? $endColumn : $this->_subject->getHighestColumn();
113 $this->_endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1;
114
115 return $this;
116 }
117
125 public function seek($column = 'A') {
127 if (($column < $this->_startColumn) || ($column > $this->_endColumn)) {
128 throw new PHPExcel_Exception("Column $column is out of range ({$this->_startColumn} - {$this->_endColumn})");
129 }
130 $this->_position = $column;
131
132 return $this;
133 }
134
138 public function rewind() {
139 $this->_position = $this->_startColumn;
140 }
141
147 public function current() {
148 return new PHPExcel_Worksheet_Column($this->_subject, PHPExcel_Cell::stringFromColumnIndex($this->_position));
149 }
150
156 public function key() {
157 return PHPExcel_Cell::stringFromColumnIndex($this->_position);
158 }
159
163 public function next() {
165 }
166
172 public function prev() {
173 if ($this->_position <= $this->_startColumn) {
174 throw new PHPExcel_Exception(
175 "Column is already at the beginning of range (" .
176 PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . " - " .
177 PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . ")"
178 );
179 }
180
182 }
183
189 public function valid() {
190 return $this->_position <= $this->_endColumn;
191 }
192}
$column
Definition: 39dropdown.php:62
An exception for terminatinating execution or to throw for unit testing.
static stringFromColumnIndex($pColumnIndex=0)
String from columnindex.
Definition: Cell.php:825
static columnIndexFromString($pString='A')
Column index from string.
Definition: Cell.php:782
next()
Set the iterator to its next value.
current()
Return the current column in this worksheet.
valid()
Indicate if more columns exist in the worksheet range of columns that we're iterating.
rewind()
Rewind the iterator to the starting column.
__construct(PHPExcel_Worksheet $subject=null, $startColumn='A', $endColumn=null)
Create a new column iterator.
key()
Return the current iterator key.