ref #1054, breaking change for the column and row's iterator
This removed 3 exported functions: `TotalCols`, `CurrentCol` and `CurrentRow`
This commit is contained in:
parent
4daa6ed0b4
commit
74f6ea94ea
|
@ -682,8 +682,10 @@ func TestSharedStringsError(t *testing.T) {
|
|||
rows, err := f.Rows("Sheet1")
|
||||
assert.NoError(t, err)
|
||||
const maxUint16 = 1<<16 - 1
|
||||
currentRow := 0
|
||||
for rows.Next() {
|
||||
if rows.CurrentRow() == 19 {
|
||||
currentRow++
|
||||
if currentRow == 19 {
|
||||
_, err := rows.Columns()
|
||||
assert.NoError(t, err)
|
||||
// Test get cell value from string item with invalid offset
|
||||
|
@ -705,8 +707,10 @@ func TestSharedStringsError(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
rows, err = f.Rows("Sheet1")
|
||||
assert.NoError(t, err)
|
||||
currentRow = 0
|
||||
for rows.Next() {
|
||||
if rows.CurrentRow() == 19 {
|
||||
currentRow++
|
||||
if currentRow == 19 {
|
||||
_, err := rows.Columns()
|
||||
assert.NoError(t, err)
|
||||
break
|
||||
|
|
10
col.go
10
col.go
|
@ -40,16 +40,6 @@ type Cols struct {
|
|||
sheetXML []byte
|
||||
}
|
||||
|
||||
// CurrentCol returns the column number that represents the current column.
|
||||
func (cols *Cols) CurrentCol() int {
|
||||
return cols.curCol
|
||||
}
|
||||
|
||||
// TotalCols returns the total columns count in the worksheet.
|
||||
func (cols *Cols) TotalCols() int {
|
||||
return cols.totalCols
|
||||
}
|
||||
|
||||
// GetCols return all the columns in a sheet by given worksheet name (case
|
||||
// sensitive). For example:
|
||||
//
|
||||
|
|
|
@ -68,8 +68,6 @@ func TestColumnsIterator(t *testing.T) {
|
|||
|
||||
for cols.Next() {
|
||||
colCount++
|
||||
assert.Equal(t, colCount, cols.CurrentCol())
|
||||
assert.Equal(t, expectedNumCol, cols.TotalCols())
|
||||
require.True(t, colCount <= expectedNumCol, "colCount is greater than expected")
|
||||
}
|
||||
assert.Equal(t, expectedNumCol, colCount)
|
||||
|
@ -85,8 +83,6 @@ func TestColumnsIterator(t *testing.T) {
|
|||
|
||||
for cols.Next() {
|
||||
colCount++
|
||||
assert.Equal(t, colCount, cols.CurrentCol())
|
||||
assert.Equal(t, expectedNumCol, cols.TotalCols())
|
||||
require.True(t, colCount <= 4, "colCount is greater than expected")
|
||||
}
|
||||
assert.Equal(t, expectedNumCol, colCount)
|
||||
|
@ -131,6 +127,11 @@ func TestGetColsError(t *testing.T) {
|
|||
cols.sheetXML = []byte(`<worksheet><sheetData><row r="1"><c r="A" t="str"><v>A</v></c></row></sheetData></worksheet>`)
|
||||
_, err = cols.Rows()
|
||||
assert.EqualError(t, err, newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error())
|
||||
|
||||
f.Pkg.Store("xl/worksheets/sheet1.xml", nil)
|
||||
f.Sheet.Store("xl/worksheets/sheet1.xml", nil)
|
||||
_, err = f.Cols("Sheet1")
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestColsRows(t *testing.T) {
|
||||
|
|
5
rows.go
5
rows.go
|
@ -79,11 +79,6 @@ type Rows struct {
|
|||
token xml.Token
|
||||
}
|
||||
|
||||
// CurrentRow returns the row number that represents the current row.
|
||||
func (rows *Rows) CurrentRow() int {
|
||||
return rows.seekRow
|
||||
}
|
||||
|
||||
// Next will return true if find the next row element.
|
||||
func (rows *Rows) Next() bool {
|
||||
rows.seekRow++
|
||||
|
|
|
@ -74,7 +74,6 @@ func TestRowsIterator(t *testing.T) {
|
|||
|
||||
for rows.Next() {
|
||||
rowCount++
|
||||
assert.Equal(t, rowCount, rows.CurrentRow())
|
||||
require.True(t, rowCount <= expectedNumRow, "rowCount is greater than expected")
|
||||
}
|
||||
assert.Equal(t, expectedNumRow, rowCount)
|
||||
|
|
Loading…
Reference in New Issue