extrame / xls

Pure Golang xls library
Apache License 2.0
331 stars 210 forks source link

WorkSheet.Row(i int) method panic #66

Open xiaoxfan opened 4 years ago

xiaoxfan commented 4 years ago

WorkSheet.Row(i int) method panic

0<= j < MaxRow ,why it panic


for i := 0; i < xlFile.NumSheets(); i++ {
    if sheet1 := xlFile.GetSheet(i); sheet1 != nil {
        for j := 0; j < (int(sheet1.MaxRow)); j++ {
            row1 := sheet1.Row(j) // panic
            for k := row1.FirstCol(); k < row1.LastCol(); k++ {
                fmt.Print(row1.Col(k), "\t")
            }
            fmt.Print("\n")
        }
    }
}
func (w *WorkSheet) Row(i int) *Row {
    row := w.rows[uint16(i)] // sometimes row is nil
    row.wb = w.wb
    return row
}
liuxinghen commented 4 years ago

I ran into this problem as well, this is because the row in your excel file is a blank row without any valid cell value and the row is in the middle of all rows. I think this is a bug.

uorji3 commented 3 years ago

I was having the same issue. The v0.0.1 release has the bug but it was fixed in https://github.com/extrame/xls/commit/7ea8f41efa35bcb7a6bcef1719835b2142166f27#diff-12d0b89bd33127025def81e7519e3efa0184ee7bef5bcd3ca3a83826459f2fb3.

I think we just need to update the version.

KiddoV commented 1 year ago

Please update this!!!!