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

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

Closed
legolas-zeng opened this issue Jul 20, 2020 · 1 comment

Comments

@legolas-zeng
Copy link

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/excelize@v1.4.1/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/excelize@v1.4.1/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/excelize@v1.4.1/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.):

@xuri
Copy link
Member

xuri commented Jul 20, 2020

This lib is not concurrently safe currently (under v2.2.0), it will support to set cell values concurrent in the next version (v2.3.0). You can try to upgrade the library with the master branch code.

@xuri xuri closed this as completed Jul 21, 2020
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