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

Setting validation drop list from one sheet to another #1019

Closed
dethlex opened this issue Sep 13, 2021 · 4 comments
Closed

Setting validation drop list from one sheet to another #1019

dethlex opened this issue Sep 13, 2021 · 4 comments
Labels
duplicate This issue or pull request already exists

Comments

@dethlex
Copy link

dethlex commented Sep 13, 2021

Description
I want to set up data validation drop list from one sheet to another, but property Formula1 in DataValidation struct not fills correctly in method SetSqrefDropList, so drop down list doesn't work properly.

For example:

dvRange := excelize.NewDataValidation(true)
dvRange.ShowErrorMessage = true
dvRange.Sqref = "A1:A1"
dvRange.SetSqrefDropList("Sheet2!$A$1:$A$3" true)
f.AddDataValidation("Sheet1", dvRange);

Possibly, instead of just setting variable
datavalidation.go:157 : dd.Formula1 = sqref
we may use special formatting
datavalidation.go:157 : dd.Formula1 = fmt.Sprintf("<formula1>%s</formula1>", sqref)

After this changes drop down list works normally.

Output of go version:

go version go1.16.4 linux/amd64

Excelize version or commit ID:

v2.4.1

Environment details (OS, Microsoft Excel™ version, physical, etc.):
OS: Linux 5.11.0-34-generic #36~20.04.1-Ubuntu SMP Fri Aug 27 08:06:32 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Office: LibreOffice Calc 6.4.7.2

@xuri
Copy link
Member

xuri commented Sep 14, 2021

Thanks for your issue, there is an incorrect absolute cell reference expression in your code, please use"Sheet2!$A$1:$A$3" instead of "Sheet2!A$1$:A$3$", it will work correctly.

@dethlex
Copy link
Author

dethlex commented Sep 14, 2021

Excuse me, I've made a mistake in this example, because I'm calculating adresses with excelize.CoordinatesToCellName and wrote there by memory :)
So, problem still exists..

@xuri xuri added the duplicate This issue or pull request already exists label Sep 14, 2021
@xuri
Copy link
Member

xuri commented Sep 14, 2021

This issue seems duplicate with #986, it has been fixed in commit 43a057b, please try to use the master branch code.

@dethlex
Copy link
Author

dethlex commented Sep 14, 2021

Ok, sorry for duplicate, thank you!

@dethlex dethlex closed this as completed Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants