Skip to content

Commit

Permalink
Merge pull request #14 from tomtwinkle/fix/csv-records-nil-value
Browse files Browse the repository at this point in the history
fix: CSVRecords ignore nil value
  • Loading branch information
tomtwinkle authored Aug 24, 2022
2 parents 9fe302c + b605fdc commit b75b9bf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion excelizeam.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,9 @@ func (e *excelizeam) CSVRecords() ([][]string, error) {
key := k.(string)
c := cached.(*Cell)
colIdx, rowIdx := e.getCacheAddress(key)
records[rowIdx-1][colIdx-1] = fmt.Sprintf("%v", c.Value)
if c.Value != nil {
records[rowIdx-1][colIdx-1] = fmt.Sprintf("%v", c.Value)
}
return true
})
return records, nil
Expand Down
1 change: 1 addition & 0 deletions excelizeam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ func TestExcelizeam_CSVRecords(t *testing.T) {
}
for colIdx := 1; colIdx <= 5; colIdx++ {
if colIdx%2 == 0 {
w.SetCellValueAsync(colIdx, rowIdx, nil, nil, false)
continue
}
w.SetCellValueAsync(colIdx, rowIdx, fmt.Sprintf("test%d-%d", rowIdx, colIdx), nil, false)
Expand Down

0 comments on commit b75b9bf

Please sign in to comment.