This closes #1874, reduces memory usage for the GetRows function (#1875)

- Avoid allocate memory for reading continuously empty rows on the tail of the worksheet
This commit is contained in:
Nima 2024-04-11 18:42:56 +03:30 committed by GitHub
parent 5f8a5b8690
commit 3e636ae7b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 1 deletions

View File

@ -70,8 +70,11 @@ func (f *File) GetRows(sheet string, opts ...Options) ([][]string, error) {
if err != nil {
break
}
results = append(results, row)
if len(row) > 0 {
if emptyRows := cur - maxVal - 1; emptyRows > 0 {
results = append(results, make([][]string, emptyRows)...)
}
results = append(results, row)
maxVal = cur
}
}