-
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
Setting style forcelluly of existing element breaks the document #1423
Comments
Same here Looks like this is a common issue... |
It worked for me... in PHPWord version 0.17 running PHP 7.4.1 I've also created public function __construct($width = null, $style = null)
{
$this->setWidth($width);
$this->setStyle($style);
}
public function setStyle($style)
{
$this->style = $this->setNewStyle(new CellStyle(), $style, true);
}
public function setWidth($width) {
$this->width = $width;
} I only modified background color on style so maybe one style is causing the problem... @captixn could you tell me which styles were you setting? I'm creating a new document but need to create all table cells before... It seems you are loading a document, isn't it? Thank you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is rather a feature request. Looking at the documentation, i have been unable to find how to either change the style of an element already created, or delete it to replace it, which creates difficulties in updating existing document rather than creating them from scratch. Forcefully editing the style breaks the document.
Expected Behavior
Locally, i added in \phpoffice\phpword\src\PhpWord\Element\Cell.php :
And call it from an object. I expect the function to set the style when I passe an array such as
Current Behavior
There seems to be no public methods to set the style of existing elements, nor there is any to delete elements of containers. I'm looking for advices as how to develop these new features. Bellow details of the unexpected result of the code :
Failure Information
None errors are raised, however the document (.docx) written is broken at the location of the table whose cell styles were edited.
The last page is not displayed.
Without calling the custom made setStyle function:
![word_with_border](https://user-images.githubusercontent.com/31285132/42642855-0a99830c-85f8-11e8-9f4d-aadda6b49998.jpg)
How to Reproduce
Add the above code to the Cell class and call it. Save the written document under .docx.
Context
The text was updated successfully, but these errors were encountered: