mirror of
https://github.com/nxshock/mssqlbulkloader.git
synced 2024-11-27 00:11:02 +05:00
Fix loading Excel rows ended with empty cells
This commit is contained in:
parent
be675c1174
commit
92f089b828
11
options.go
11
options.go
@ -60,3 +60,14 @@ type Options struct {
|
|||||||
// Column names list
|
// Column names list
|
||||||
columnNames []string
|
columnNames []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *Options) fieldCount() int {
|
||||||
|
fCount := 0
|
||||||
|
for i := range o.fieldsTypes {
|
||||||
|
if o.fieldsTypes[i] != ' ' {
|
||||||
|
fCount++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fCount
|
||||||
|
}
|
||||||
|
@ -109,6 +109,8 @@ func (r *XlsxReader) GetRow(asStrings bool) ([]any, error) {
|
|||||||
args = append(args, parsedValue)
|
args = append(args, parsedValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
args = append(args, make([]any, r.options.fieldCount()-len(args))...)
|
||||||
|
|
||||||
return args, nil
|
return args, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,10 @@ func TestXlsxReaderBasic(t *testing.T) {
|
|||||||
assert.Equal(t, []any{"7710146208", nil, nil, "99386901", "99386901", "304722813269", "TSENTRALNYY TELEGRAF", "780000334079", "780000334079", "10432641", t1, t2, 50.00, 0.80, 49.20, "553691******1214", "026094", "D", "MC OTHER"}, row)
|
assert.Equal(t, []any{"7710146208", nil, nil, "99386901", "99386901", "304722813269", "TSENTRALNYY TELEGRAF", "780000334079", "780000334079", "10432641", t1, t2, 50.00, 0.80, 49.20, "553691******1214", "026094", "D", "MC OTHER"}, row)
|
||||||
|
|
||||||
row, err = xlsxReader.GetRow(false)
|
row, err = xlsxReader.GetRow(false)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Len(t, row, 19)
|
||||||
|
|
||||||
|
_, err = xlsxReader.GetRow(false)
|
||||||
assert.Equal(t, io.EOF, err)
|
assert.Equal(t, io.EOF, err)
|
||||||
|
|
||||||
err = xlsxReader.Close()
|
err = xlsxReader.Close()
|
||||||
|
BIN
testdata/xlsx/38_049RMZ_all.xlsx
vendored
BIN
testdata/xlsx/38_049RMZ_all.xlsx
vendored
Binary file not shown.
Loading…
Reference in New Issue
Block a user