Skip to content

Delete sheet breaks AutoFilter  #775

@pandaadb

Description

@pandaadb

Description

When using autoFilter, removing Sheet1 seems to be breaking the entire file.

This is tested with LibreOffice on ubuntu.

When uploaded to Office365, it says the file has been repaired.

Steps to reproduce the issue:

Code:

        f := excelize.NewFile()

	f.NewSheet("sheet_test")
	for i := 0; i < 5; i++ {
		idx, _ := excelize.CoordinatesToCellName(i+1, 1)
		f.SetCellValue("sheet_test", idx, fmt.Sprintf("Header %d", i))
	}

	row := 2

	for j := 0; j < 10; j++ {

		for i := 0; i < 5; i++ {
			idx, _ := excelize.CoordinatesToCellName(i+1, row)
			f.SetCellValue("sheet_test", idx, fmt.Sprintf("Value %d", i))
		}

		row++
	}

	f.AutoFilter("sheet_test", "A1", "E11", "")

	f.DeleteSheet("Sheet1")
	f.SetActiveSheet(0)

	filename := "/tmp/test4.xlsx"

	f.SaveAs(filename)

Describe the results you received:

When opening the file, Libre office reports:

General input/output error

Describe the results you expected:

A 1 sheet xlsx file, containing the Autofilter.

Output of go version:

go version go1.13.10 linux/amd64

Excelize version or commit ID:

github.com/360EntSecGroup-Skylar/excelize/v2 v2.3.2

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

Ubuntu 18.04
LibreOffice (LibreOffice 6.0.7.3 00m0(Build:3)

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