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

adjustDataValidations skips adjusting data validations on subsequent sheets if the first sheet has no data validations #2072

Closed
2 tasks done
gypsy1234 opened this issue Jan 21, 2025 · 0 comments · Fixed by #2073
Labels
bug Something isn't working

Comments

@gypsy1234
Copy link
Contributor

gypsy1234 commented Jan 21, 2025

Description

The adjustDataValidations function, which is invoked by operations such as RemoveCol, skips properly adjusting data validations on subsequent sheets if the first sheet in a workbook has no data validations.

Steps to reproduce the issue

t.Run("no_data_validations_on_first_sheet", func(t *testing.T) {
	f := NewFile()

	// Add Sheet2 and set a data validation
	_, err = f.NewSheet("Sheet2")
	assert.NoError(t, err)
	dv := NewDataValidation(true)
	dv.Sqref = "C5:D6"
	assert.NoError(t, f.AddDataValidation("Sheet2", dv))

	// Adjust Sheet2 by removing a column
	assert.NoError(t, f.RemoveCol("Sheet2", "A"))

	// Verify that data validations on Sheet2 are adjusted correctly
	dvs, err = f.GetDataValidations("Sheet2")
	assert.NoError(t, err)
	assert.Equal(t, "B5:C6", dvs[0].Sqref) // test failed
})

Describe the results you received

DataValidation not updated

Describe the results you expected

DataValidation adjusted

Go version

go version go1.22.2 darwin/arm64

Excelize version or commit ID

2.9.0

Environment

Mac

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Bugfix
2 participants