summaryrefslogtreecommitdiff
path: root/rows.go
diff options
context:
space:
mode:
authorli <liying0721@vip.126.com>2021-11-05 00:01:34 +0800
committerGitHub <noreply@github.com>2021-11-05 00:01:34 +0800
commit60b13affbda954261888a7829c88a32993edb5b2 (patch)
treef0d4cedb6003eb8c57c20f36407ca2d4084dd505 /rows.go
parente64775fdcc38a9bc882ef32b4d4d491ad63acbdd (diff)
Support get current row/col and total rows/cols in the stream reader (#1054)
Diffstat (limited to 'rows.go')
-rw-r--r--rows.go28
1 files changed, 19 insertions, 9 deletions
diff --git a/rows.go b/rows.go
index 3171ab1..1e20f0a 100644
--- a/rows.go
+++ b/rows.go
@@ -67,19 +67,29 @@ func (f *File) GetRows(sheet string, opts ...Options) ([][]string, error) {
// Rows defines an iterator to a sheet.
type Rows struct {
- err error
- curRow, totalRow, stashRow int
- rawCellValue bool
- sheet string
- f *File
- tempFile *os.File
- decoder *xml.Decoder
+ err error
+ curRow, totalRows, stashRow int
+ rawCellValue bool
+ sheet string
+ f *File
+ tempFile *os.File
+ decoder *xml.Decoder
+}
+
+// CurrentRow returns the row number that represents the current row.
+func (rows *Rows) CurrentRow() int {
+ return rows.curRow
+}
+
+// TotalRows returns the total rows count in the worksheet.
+func (rows *Rows) TotalRows() int {
+ return rows.totalRows
}
// Next will return true if find the next row element.
func (rows *Rows) Next() bool {
rows.curRow++
- return rows.curRow <= rows.totalRow
+ return rows.curRow <= rows.totalRows
}
// Error will return the error when the error occurs.
@@ -255,7 +265,7 @@ func (f *File) Rows(sheet string) (*Rows, error) {
}
}
}
- rows.totalRow = row
+ rows.totalRows = row
}
case xml.EndElement:
if xmlElement.Name.Local == "sheetData" {