Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime error SIGSEGV on 8fbab474 #50

Closed
dlintw opened this issue May 5, 2017 · 1 comment
Closed

runtime error SIGSEGV on 8fbab474 #50

dlintw opened this issue May 5, 2017 · 1 comment

Comments

@dlintw
Copy link

dlintw commented May 5, 2017

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
}

@xuri
Copy link
Member

xuri commented May 5, 2017

@dlintw Thanks for your issue. This library just supports Excel's built-in formats currently. The built-in number formats index (numFmtId) in the attachment is out of this range. I will handle this exception by returning the raw value. You can use function SetCellStyle() with built-in number format index by number_format property before GetRows().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants