ref #1054, breaking change for the column and row's iterator

This removed 3 exported functions: `TotalCols`, `CurrentCol` and `CurrentRow`
pull/2/head
xuri 3 years ago
parent 4daa6ed0b4
commit 74f6ea94ea
No known key found for this signature in database
GPG Key ID: BA5E5BB1C948EDF7

@ -682,8 +682,10 @@ func TestSharedStringsError(t *testing.T) {
rows, err := f.Rows("Sheet1") rows, err := f.Rows("Sheet1")
assert.NoError(t, err) assert.NoError(t, err)
const maxUint16 = 1<<16 - 1 const maxUint16 = 1<<16 - 1
currentRow := 0
for rows.Next() { for rows.Next() {
if rows.CurrentRow() == 19 { currentRow++
if currentRow == 19 {
_, err := rows.Columns() _, err := rows.Columns()
assert.NoError(t, err) assert.NoError(t, err)
// Test get cell value from string item with invalid offset // Test get cell value from string item with invalid offset
@ -705,8 +707,10 @@ func TestSharedStringsError(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
rows, err = f.Rows("Sheet1") rows, err = f.Rows("Sheet1")
assert.NoError(t, err) assert.NoError(t, err)
currentRow = 0
for rows.Next() { for rows.Next() {
if rows.CurrentRow() == 19 { currentRow++
if currentRow == 19 {
_, err := rows.Columns() _, err := rows.Columns()
assert.NoError(t, err) assert.NoError(t, err)
break break

@ -40,16 +40,6 @@ type Cols struct {
sheetXML []byte 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 // GetCols return all the columns in a sheet by given worksheet name (case
// sensitive). For example: // sensitive). For example:
// //

@ -68,8 +68,6 @@ func TestColumnsIterator(t *testing.T) {
for cols.Next() { for cols.Next() {
colCount++ colCount++
assert.Equal(t, colCount, cols.CurrentCol())
assert.Equal(t, expectedNumCol, cols.TotalCols())
require.True(t, colCount <= expectedNumCol, "colCount is greater than expected") require.True(t, colCount <= expectedNumCol, "colCount is greater than expected")
} }
assert.Equal(t, expectedNumCol, colCount) assert.Equal(t, expectedNumCol, colCount)
@ -85,8 +83,6 @@ func TestColumnsIterator(t *testing.T) {
for cols.Next() { for cols.Next() {
colCount++ colCount++
assert.Equal(t, colCount, cols.CurrentCol())
assert.Equal(t, expectedNumCol, cols.TotalCols())
require.True(t, colCount <= 4, "colCount is greater than expected") require.True(t, colCount <= 4, "colCount is greater than expected")
} }
assert.Equal(t, expectedNumCol, colCount) 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>`) cols.sheetXML = []byte(`<worksheet><sheetData><row r="1"><c r="A" t="str"><v>A</v></c></row></sheetData></worksheet>`)
_, err = cols.Rows() _, err = cols.Rows()
assert.EqualError(t, err, newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error()) 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) { func TestColsRows(t *testing.T) {

@ -79,11 +79,6 @@ type Rows struct {
token xml.Token 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. // Next will return true if find the next row element.
func (rows *Rows) Next() bool { func (rows *Rows) Next() bool {
rows.seekRow++ rows.seekRow++

@ -74,7 +74,6 @@ func TestRowsIterator(t *testing.T) {
for rows.Next() { for rows.Next() {
rowCount++ rowCount++
assert.Equal(t, rowCount, rows.CurrentRow())
require.True(t, rowCount <= expectedNumRow, "rowCount is greater than expected") require.True(t, rowCount <= expectedNumRow, "rowCount is greater than expected")
} }
assert.Equal(t, expectedNumRow, rowCount) assert.Equal(t, expectedNumRow, rowCount)

Loading…
Cancel
Save