-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Allow ANCHORARRAY as Valid DataValidation List #4203
Conversation
Fix PHPOffice#4197. Overlooked in the introduction of Dynamic Arrays, Data Validation can specify a list to be a result of the spill operator, which is implemented via the ANCHORARRAY function. It appears that function `DataValidator::isValid` will not work if the list is specified in this manner, nor if it is specified as a defined name. Fixing those situations will be difficult (defined names probably easier than ANCHORARRAY), and there is no reason to delay this change waiting for those to be fixed. I will open a new issue when this PR is merged.
@oleibman it is does not work with russia words ![]()
|
@siarheipashkevich I am unable to duplicate your error. Perhaps it comes farther along in the code than what you have identified. At any rate, here's the code I used (I changed cell B0 to B1 - I'm a bit surprised that your references to B0 did not cause an exception): public static function issue(): void
{
$spreadsheet = new Spreadsheet();
$worksheet = $spreadsheet->getActiveSheet();
$validation = $worksheet->getCell('B1')->getDataValidation();
$validation->setType(DataValidation::TYPE_LIST);
$validation->setErrorStyle(DataValidation::STYLE_STOP);
$validation->setAllowBlank(false);
$validation->setShowInputMessage(true);
$validation->setShowErrorMessage(true);
$validation->setShowDropDown(true);
$validation->setFormula1('"слово, слово"'); // << russia words here
$dataValidator = new DataValidator();
$worksheet->getCell('B1')->setValue('слово');
// expect true
var_dump($dataValidator->isValid($worksheet->getCell('B1')));
$worksheet->getCell('B1')->setValue('слов');
// expect false
var_dump($dataValidator->isValid($worksheet->getCell('B1')));
$worksheet->setDataValidation('B2:B1500', clone $validation);
echo "Done\n";
} And here are my results, exactly as expected:
|
@oleibman thanks for your response. Do you use |
@siarheipashkevich I just tried with 1.29.9 and received the same expected results without any exceptions. |
@oleibman it's very strange. Could you please check this issue SpartnerNL/Laravel-Excel#4266 where I attached more code? |
Aha, the error does show up later than you reported. It happens when I try to save the spreadsheet as Xls. And, yes, it does not happen with Latin characters. I will research. In the meantime, you can save the spreadsheet as Xlsx instead without problems. |
@oleibman thanks, I'll wait your solution. |
It currently parsed by byte, which is not a good thing in a UTF-8 system. See the discussion at the bottom of PR PHPOffice#4203. That turns out to not be the change which led to this problem; that would have been PR PHPOffice#4323. That change came about because using Composer/Pcre revealed bugs in several regular expressions used in Writer/Xls/Parser. This ticket comes about because more bugs were revealed in the same module. The problem is that the `advance` method needs to process formulas character by character, but is instead doing it byte by byte. It is changed to advance by characters, and tests for non-ASCII characters are added.
@siarheipashkevich If you can test against the parseutf8 branch (or, guessing from our conversation, the release1291 branch), please do so. |
@oleibman unfortunately I can't, because I use laravel-excel package. Only if you create a new patch release in that case I'll possible to check. |
New releases are now available. |
@oleibman it's working right now, thank you so much 🚀 |
Fix #4197. Overlooked in the introduction of Dynamic Arrays, Data Validation can specify a list to be a result of the spill operator, which is implemented via the ANCHORARRAY function.
It appears that function
DataValidator::isValid
will not work if the list is specified in this manner, nor if it is specified as a defined name. Fixing those situations will be difficult (defined names probably easier than ANCHORARRAY), and there is no reason to delay this change waiting for those to be fixed. I will open a new issue when this PR is merged.This is:
Checklist:
Why this change is needed?
Provide an explanation of why this change is needed, with links to any Issues (if appropriate).
If this is a bugfix or a new feature, and there are no existing Issues, then please also create an issue that will make it easier to track progress with this PR.