panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4d96f7]
goroutine 1 [running]:
github.com/Luxurioust/excelize.(*File).formattedValue(0xc4200504b0, 0x1, 0xc4200f9982, 0x6, 0x0, 0x0)
/home/dlin/go/src/github.com/Luxurioust/excelize/cell.go:69 +0x177
github.com/Luxurioust/excelize.(*xlsxC).getValueFrom(0xc4200edd70, 0xc4200504b0, 0xc420050820, 0xc4201148d0, 0x1, 0x0, 0x2)
/home/dlin/go/src/github.com/Luxurioust/excelize/rows.go:144 +0x15b
github.com/Luxurioust/excelize.(*File).GetRows(0xc4200504b0, 0xc4200edea0, 0x6, 0xc42001159c, 0x1, 0xc4200edea0)
/home/dlin/go/src/github.com/Luxurioust/excelize/rows.go:60 +0x9e8
main.updateSheet(0xc4200504b0, 0x531640, 0x3)
/home/dlin/tmp/bug/bug.go:28 +0xd2
main.main()
/home/dlin/tmp/bug/bug.go:15 +0x6f
t.xlsx
package main
import (
"fmt"
"log"
"strconv"
"github.com/Luxurioust/excelize" // bug: Date format, can't insert value
)
func main() {
log.SetFlags(log.Lshortfile)
xl, err := excelize.OpenFile("t.xlsx")
updateSheet(xl, "Fut")
err = xl.Save()
if err != nil {
log.Fatalln(err)
}
}
func updateSheet(xl *excelize.File, sheetName string) {
idxSheet := xl.GetSheetIndex(sheetName)
if idxSheet == 0 {
log.Fatalln("Can't found correct sheetName:", sheetName)
}
rows := xl.GetRows("sheet" + strconv.Itoa(idxSheet))
fmt.Println(rows)
}
func GetColStr(x int) string {
colName := ""
//oldX := x
for x > 0 {
digit := (x - 1) % 26
colName = string(int('A')+digit) + colName
x = (x - 1 - digit) / 26
}
//log.Println(oldX, colName)
return colName
}