xls icon indicating copy to clipboard operation
xls copied to clipboard

WorkSheet.Row(i int) method panic

Open xiaoxfan opened this issue 4 years ago • 3 comments

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
}

xiaoxfan avatar May 21 '20 09:05 xiaoxfan

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.

liuxinghen avatar May 22 '20 02:05 liuxinghen

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.

uorji3 avatar May 26 '21 14:05 uorji3

Please update this!!!!

KiddoV avatar Apr 17 '23 12:04 KiddoV