Skip to content

Commit

Permalink
Merge pull request #357 from nlimpid/master
Browse files Browse the repository at this point in the history
fix the wrong number of counting the rest empty rows
  • Loading branch information
ryho authored Feb 1, 2018
2 parents 286dc03 + a7ea62a commit 1fe99bc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ func readRowsFromSheet(Worksheet *xlsxWorksheet, file *File, sheet *Sheet, rowLi
}

// insert trailing empty rows for the rest of the file
for ; insertRowIndex < maxRow; insertRowIndex++ {
for ; insertRowIndex < rowCount; insertRowIndex++ {
rows[insertRowIndex] = makeEmptyRow(sheet)
}
return rows, cols, colCount, rowCount
Expand Down
12 changes: 12 additions & 0 deletions lib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1346,3 +1346,15 @@ func (l *LibSuite) TestRoundTripFileWithNoSheetCols(c *C) {
c.Assert(err, IsNil)
os.Remove("testdocs/after_write.xlsx")
}

func (l *LibSuite) TestReadRestEmptyRowsFromSheet(c *C) {
originalXlFile, err := OpenFile("testdocs/empty_rows_in_the_rest.xlsx")
c.Assert(err, IsNil)
for _, sheet := range originalXlFile.Sheets {
for _, row := range sheet.Rows {
if row == nil {
c.Errorf("Row should not be nil")
}
}
}
}
Binary file added testdocs/empty_rows_in_the_rest.xlsx
Binary file not shown.

0 comments on commit 1fe99bc

Please sign in to comment.