Skip to content

use goroutine,return "panic: runtime error: index out of range [321] with length 321" #670

@legolas-zeng

Description

@legolas-zeng

Description

Steps to reproduce the issue:
1.use oracle databases get 48000+ datas
2.use goroute Write the data to Excel
3.An error "panic: runtime error: index out of range [321] with length 321"

Describe the results you received:

for k,v := range data{
    go func(k int,v map[string]string) {
	waitgroup.Add(1)
	fmt.Println("-----",k,v)
	//行数k
	a := 0
	for _,j:= range []string{"STORE_NAME","ORIGINAL_STRUCT_NAME","CONTRACT_NO","CUSTOMER_NAME","APPROVED_AMOUNT","BORROW_MONEY","CONTRACT_DURATION","REPAY_WAY","LEND_DATE" ,"FISRT_PERIOD_REPAY","LAST_PERIOD_REPAY","FIRST_JH_MONEY","MONTH_JH_MONEY","REPAY_DATE","JH_MONEY","SY_REPAY_PRINCIPAL","SETTLE_PERIOD","IS_SETTLE","YQ_DAYS"} {
	col := GetLetterByNum(a+1)
	fmt.Println("数据:",col + strconv.Itoa(k+2),v[j])
	xlsx.SetCellValue("Sheet1",col + strconv.Itoa(k+2),v[j])
	a ++
	}
	defer waitgroup.Done()
	}(k,v)
}
waitgroup.Wait()
fmt.Println("开始保存表格......")
err := xlsx.SaveAs("C:\\Users\\Administrator.000\\Desktop\\Workbook.xlsx")

Describe the results you expected:

panic: runtime error: index out of range [321] with length 321

goroutine 37 [running]:
github.com/360EntSecGroup-Skylar/excelize.completeRow(0xc000092640, 0x1c0, 0x1)
	E:/GOPATH/pkg/mod/github.com/360!ent!sec!group-!skylar/[email protected]/rows.go:486 +0x54f
github.com/360EntSecGroup-Skylar/excelize.(*File).SetCellStr(0xc000342000, 0x645df8, 0x6, 0xc00018479c, 0x4, 0xc0002f8b30, 0xf)
	E:/GOPATH/pkg/mod/github.com/360!ent!sec!group-!skylar/[email protected]/cell.go:498 +0x193
github.com/360EntSecGroup-Skylar/excelize.(*File).SetCellValue(0xc000342000, 0x645df8, 0x6, 0xc00018479c, 0x4, 0x5f8c20, 0xc0001820f0)
	E:/GOPATH/pkg/mod/github.com/360!ent!sec!group-!skylar/[email protected]/cell.go:77 +0x586
main.handledata.func1(0xc000342000, 0x1be, 0xc0002ab440)
	D:/GoleGolas/sql/InterfaceOracle/main.go:151 +0x3f8
created by main.handledata
	D:/GoleGolas/sql/InterfaceOracle/main.go:143 +0x248

Output of go version:

1.14

Excelize version or commit ID:

latest

Environment details (OS, Microsoft Excel™ version, physical, etc.):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions