forked from plandem/xlsx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
row_iterator.go
40 lines (32 loc) · 1.01 KB
/
row_iterator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2017 Andrey Gayvoronsky <plandem@gmail.com>
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package xlsx
//RowIterator is a interface for iterating rows inside of sheet
type RowIterator interface {
//Next returns next Row in sheet and corresponding index
Next() (idx int, row *Row)
//HasNext returns true if there are rows to iterate or false in other case
HasNext() bool
}
//rowIterator is object that holds required information for common row's iterator
type rowIterator struct {
idx int
sheet Sheet
}
var _ RowIterator = (*rowIterator)(nil)
func newRowIterator(sheet Sheet) RowIterator {
return &rowIterator{
idx: -1,
sheet: sheet,
}
}
//Next returns next Row in sheet and corresponding index
func (i *rowIterator) Next() (int, *Row) {
i.idx++
return i.idx, i.sheet.Row(i.idx)
}
//HasNext returns true if there are rows to iterate or false in other case
func (i *rowIterator) HasNext() bool {
return i.sheet.HasRow(i.idx + 1)
}