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

Delete Sheet index error #308

Closed
ogimenezb opened this issue Dec 14, 2018 · 2 comments
Closed

Delete Sheet index error #308

ogimenezb opened this issue Dec 14, 2018 · 2 comments

Comments

@ogimenezb
Copy link

Description

When you delete a sheet then create a new one and then delete again there is an out of index error

Steps to reproduce the issue:

func main() {
    xlsx := excelize.NewFile()
    // Create a new sheet.
	xlsx.NewSheet("Sheet2")
	xlsx.NewSheet("Sheet3")
	xlsx.NewSheet("Sheet4")
	fmt.Println("init ", xlsx.GetSheetMap())
	xlsx.DeleteSheet("Sheet3")
	fmt.Println("delete ", xlsx.GetSheetMap())
	xlsx.NewSheet("Sheet5")
	fmt.Println("new ", xlsx.GetSheetMap())
	xlsx.DeleteSheet("Sheet5")
	fmt.Println("delete ", xlsx.GetSheetMap())
    err := xlsx.SaveAs("./Book1.xlsx")
    if err != nil {
        fmt.Println(err)
    }
}

Describe the results you received:

$ go run main.go
init  map[1:Sheet1 2:Sheet2 3:Sheet3 4:Sheet4]
delete  map[1:Sheet1 2:Sheet2 4:Sheet4]
new  map[1:Sheet1 2:Sheet2 4:Sheet5]
panic: runtime error: slice bounds out of range

goroutine 1 [running]:
github.com/360EntSecGroup-Skylar/excelize.(*File).deleteSheetFromContentTypes(0xc0002a2000, 0xc00005cde0, 0x15)
        C:/Users/xx/go/pkg/mod/github.com/360!ent!sec!group-!skylar/[email protected]/sheet.go:439 +0x2cd
github.com/360EntSecGroup-Skylar/excelize.(*File).DeleteSheet(0xc0002a2000, 0x6a15ea, 0x6)
        C:/Users/xx/go/pkg/mod/github.com/360!ent!sec!group-!skylar/[email protected]/sheet.go:408 +0x45b
main.main()
        C:/data/main.go:25 +0x275
exit status 2

Describe the results you expected:
To not have an error
Output of go version:

go version go1.11.1 windows/amd64
@xuri xuri added the confirmed This issue can be reproduced label Dec 14, 2018
@xuri xuri closed this as completed in e728ff1 Dec 14, 2018
@xuri
Copy link
Member

xuri commented Dec 14, 2018

Hi @ogimenezb, thanks for your issue. I have fixed it. Please try to upgrade the library to the last version.

@ogimenezb
Copy link
Author

Hi @xuri, thanks for your quick fix.

Just tested the latest version and works perfectly!

@xuri xuri removed the confirmed This issue can be reproduced label Dec 14, 2018
nullfy pushed a commit to nullfy/excelize that referenced this issue Oct 23, 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