summaryrefslogtreecommitdiff
path: root/excelize.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2020-06-27 00:02:47 +0800
committerxuri <xuri.me@gmail.com>2020-06-27 00:02:47 +0800
commit48f19f60aa3e162146a9dc4edf7b4c8cf687ec26 (patch)
tree77fdff8dba0fbb26f8c534872f06a98258c1c273 /excelize.go
parent15fd56853fe1b63217fb963c951cf4fef7b56a08 (diff)
support the row element without r attribute in the worksheet
Diffstat (limited to 'excelize.go')
-rw-r--r--excelize.go21
1 files changed, 15 insertions, 6 deletions
diff --git a/excelize.go b/excelize.go
index 3e0255a..970759c 100644
--- a/excelize.go
+++ b/excelize.go
@@ -191,16 +191,25 @@ func (f *File) workSheetReader(sheet string) (xlsx *xlsxWorksheet, err error) {
// checkSheet provides a function to fill each row element and make that is
// continuous in a worksheet of XML.
func checkSheet(xlsx *xlsxWorksheet) {
- row := len(xlsx.SheetData.Row)
- if row >= 1 {
- lastRow := xlsx.SheetData.Row[row-1].R
- if lastRow >= row {
- row = lastRow
+ var row int
+ for _, r := range xlsx.SheetData.Row {
+ if r.R != 0 && r.R > row {
+ row = r.R
+ continue
}
+ row++
}
sheetData := xlsxSheetData{Row: make([]xlsxRow, row)}
+ row = 0
for _, r := range xlsx.SheetData.Row {
- sheetData.Row[r.R-1] = r
+ if r.R != 0 {
+ sheetData.Row[r.R-1] = r
+ row = r.R
+ continue
+ }
+ row++
+ r.R = row
+ sheetData.Row[row-1] = r
}
for i := 1; i <= row; i++ {
sheetData.Row[i-1].R = i