Skip to content

RemoveRow can not remove the last row|RemoveRow 无法删除最后一行 #686

@liserjrqlxue

Description

@liserjrqlxue

Description

RemoveRow can not remove the last row|RemoveRow 无法删除最后一行:

  1. RemoveRow(sheetName,0) report error: invalid row number 0 []
  2. RemoveRow(sheetName,i+1) remove the i+1 th row as rows[i] from GetRows(sheetName)
  3. RemoveRow(sheetName,len(row)) report error : slice bounds out of range [94:93] (94:93 is example)

Steps to reproduce the issue:

  1. var excel,err1=excelize.OpenFile(excelFile)
  2. var rows,err2=excel.GetRows(sheetName)
  3. excel.RemoveRow(sheetName,len(rows))

Describe the results you received:

panic: runtime error: slice bounds out of range [94:93]

goroutine 1 [running]:
github.com/360EntSecGroup-Skylar/excelize/v2.(*File).adjustHyperlinks(0xc000126500, 0xc00007c000, 0x5a4327, 0x11, 0x1, 0x11, 0xffffffffffffffff)
	/home/wangyaoshen/go/pkg/mod/github.com/360!ent!sec!group-!skylar/excelize/[email protected]/adjust.go:117 +0x5a1
github.com/360EntSecGroup-Skylar/excelize/v2.(*File).adjustHelper(0xc000126500, 0x5a4327, 0x11, 0xc00007c001, 0x11, 0xffffffffffffffff, 0xc0000100f0, 0x2)
	/home/wangyaoshen/go/pkg/mod/github.com/360!ent!sec!group-!skylar/excelize/[email protected]/adjust.go:45 +0xdd
github.com/360EntSecGroup-Skylar/excelize/v2.(*File).RemoveRow(0xc000126500, 0x5a4327, 0x11, 0x11, 0x4, 0x0)
	/home/wangyaoshen/go/pkg/mod/github.com/360!ent!sec!group-!skylar/excelize/[email protected]/rows.go:436 +0x199
main.main()
	/zfsyt1/B2C_RD_P2/USER/wangyaoshen/pipeline/filterExcel/main.go:146 +0x13dc

Describe the results you expected:

RemoveRow(sheetName,len(rows)) remove the len(rows) th row (the last row) as rows[len(rows)-1]

Output of go version:

go version go1.14.3 linux/amd64

Excelize version or commit ID:

v2.2.0

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