Closed ayushjain1908 closed 4 months ago
in v2.8.0 the output seems right.here is my test code:
func TestMyTest3(t *testing.T) {
f := excelize.NewFile()
defer f.Close()
_, err := f.NewSheet("Sheet2")
if err != nil {
fmt.Println(err)
}
f.SetCellValue("Sheet2", "B1", 1)
f.SetCellValue("Sheet2", "B5", 5)
dv := excelize.NewDataValidation(true)
dv.Sqref = "A7:B8"
dv.SetSqrefDropList("Sheet2!$B$1:$B$5")
err = f.AddDataValidation("Sheet1", dv)
if err != nil {
fmt.Println(err)
}
dvs, err := f.GetDataValidations("Sheet1")
if err != nil {
fmt.Println(err)
}
for _, v := range dvs {
fmt.Println(v)
}
}
Output of code: === RUN TestMyTest3
=== RUN TestMyTest3
&{true <nil> <nil> <nil> <nil> <nil> false false false A7:B8 list <formula1>Sheet2!$B$1:$B$5</formula1> }
--- PASS: TestMyTest3 (0.00s)
PASS
ok p1 0.003s
could you please show your test code
it is not working for sheets where data validation is added using Excel and we are just reading all the validations in the program, may be working for validations added using the library in Go program I think this recently created PR https://github.com/qax-os/excelize/pull/1834 addresses this issue
Thanks for your issue. The pull request #1834 has been merged. The GetDataValidations
function now support get data validations which storage in the extension lists. Please upgrade to the master branch by go get -u github.com/xuri/excelize/v2@master
, and this changes will be released in the next version.
Description Calling GetDataValidations for a particular sheet does not list those validations(list/dropdown types) which reference another sheet in the same workbook.
Steps to reproduce the issue:
Describe the results you received: Cross sheet referenced validations do not appear in the result. Describe the results you expected: Dropdown validation should appear Output of
go version
:Excelize version or commit ID:
Environment details (OS, Microsoft Excel™ version, physical, etc.): macOS Ventura 13.3.1