Skip to content

Commit

Permalink
ref qax-os#1054, breaking change for the column and row's iterator
Browse files Browse the repository at this point in the history
This removed 3 exported functions: `TotalCols`, `CurrentCol` and `CurrentRow`
  • Loading branch information
xuri committed Oct 9, 2022
1 parent b0fa432 commit 4f5b007
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 22 deletions.
8 changes: 6 additions & 2 deletions cell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 0 additions & 10 deletions col.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
//
Expand Down
9 changes: 5 additions & 4 deletions col_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 0 additions & 5 deletions rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++
Expand Down
1 change: 0 additions & 1 deletion rows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4f5b007

Please sign in to comment.