-
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
Xls and Xlsx readers miss data validation for files saved with Excel #388
Comments
Could you suggest a PR for that ? |
that's planned, but can't do it before April! |
So the error comes from simplexml_load_string() failing to read Microsoft extensions (see https://msdn.microsoft.com/en-us/library/dd905242(v=office.12).aspx) In my case the xml looks like this:
The call only loads the uri attribute of the ext element. |
…ataValidations.
…cEngine_errors' and 'PHPOffice#388-Xlsx_MSextensions' into develop-merges
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
PHPOffice#388 xlsx m sextensions
FYI. I am still encountering this issue. The provided fix and pull request does work for me. |
The PR still misses tests to be merged, consider contributing some if you can. |
I think there is a problem with that code, if I dont have data validations on the same sheet it not going to enter in the if condition. I think that it must be outside of the if condition on line 1337. |
Can you provide more context (branch, commit ID, ...) about the code you're mentioning, as well as a test for this case? |
Im talking about this line I think this works if you dont have data validation in the same sheet <?php
if (isset ($xmlSheet->extLst, $xmlSheet->extLst->ext, $xmlSheet->extLst->ext['uri'])
&& $xmlSheet->extLst->ext['uri'] == "{CCE6A557-97BC-4b89-ADB6-D9C93CAAB3DF}" ) {
// Create dataValidations node if does not exists, maybe is better inside the foreach ?
if(!$xmlSheet->dataValidations) {
$xmlSheet->addChild('dataValidations');
}
foreach ($xmlSheet->extLst->ext->children('x14', TRUE)->dataValidations->dataValidation as $item) {
$node = $xmlSheet->dataValidations->addChild('dataValidation');
foreach ($item->attributes() as $attr) {
$node->addAttribute($attr->getName(), $attr);
$node->addAttribute('sqref', $item->children('xm',TRUE)->sqref);
$node->addChild('formula1', $item->formula1->children('xm',TRUE)->f);
}
}
}
if ($xmlSheet && $xmlSheet->dataValidations && !$this->readDataOnly) {
// Continue PhpSpreadhseet code....
} |
…ataValidations.
…ataValidations even if only present as MS extensions.
Make sure there is no space in your Sheet name in |
thanks, worked successfully. |
Did someone created a pull request for this? Cause with the actual version of PHPOffice/PhpSpreadsheet this code is not included and I also still have this problem. |
Any updates about this? |
Fix was provided by PR #3681 in August 2023. |
This is:
What is the expected behavior?
Readers should be able to read cells' DataValidation info from .xls and .xlsx files wether or not they are generated by MS-Excel or PhpSpreadsheet.
What is the current behavior?
Currently, xls and xlsx files generated with PhpSpreadsheet, then opened and saved with MS-Excel are missing all cross-sheet DataValidation of the form "sheet_name!ref:ref" .
In this case, calling getDataValidationCollection() will only return correct DataValidation for cells in the target sheet.
What are the steps to reproduce?
Which versions of PhpSpreadsheet and PHP are affected?
development branch, php 5.6, MS Excel Office 2010
The text was updated successfully, but these errors were encountered: