-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
vMerge value is Empty in MS Word 2021 #2330
Comments
I can suggest a solution. In method PHPWord/src/PhpWord/Reader/Word2007/AbstractPart.php Lines 624 to 653 in 0af4ca1
Modify the code as follows protected function readStyleDefs(XMLReader $xmlReader, ?DOMElement $parentNode = null, $styleDefs = [])
{
$styles = [];
foreach ($styleDefs as $styleProp => $styleVal) {
[$method, $element, $attribute, $expected, $default] = array_pad($styleVal, 4, null);
$element = $this->findPossibleElement($xmlReader, $parentNode, $element);
if ($element === null) {
continue;
}
if ($xmlReader->elementExists($element, $parentNode)) {
$node = $xmlReader->getElement($element, $parentNode);
$attribute = $this->findPossibleAttribute($xmlReader, $node, $attribute);
// Use w:val as default if no attribute assigned
$attribute = ($attribute === null) ? 'w:val' : $attribute;
$attributeValue = $xmlReader->getAttribute($attribute, $node) ?? $default;
$styleValue = $this->readStyleDef($method, $attributeValue, $expected);
if ($styleValue !== null) {
$styles[$styleProp] = $styleValue;
}
}
}
return $styles;
} This will allow default values to be passed for empty attributes. For example in a cell styles
The code will look like this 'vMerge' => [self::READ_VALUE, 'w:vMerge', null, null, 'continue'], |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the Bug
In MS Word 2021 docx files save with empty
w:val
ofw:vMerge
when expected value "continue".Steps to Reproduce
I tried saving:
In both cases I get the described problem
When I save in Libre Office the problem doesn't reproduce
What does this have to do with phpword?
When I want to save a file in html or pdf I get incorrect markup
Context
Please fill in your environment information:
The text was updated successfully, but these errors were encountered: