-
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
Support comments in docx documents #1059
Conversation
…_field' into develop
…ttps' into develop
'github_troosan/fix_for_different_even_odd_headers' into develop Conflicts: tests/PhpWord/SettingsTest.php tests/PhpWord/Writer/Word2007/Part/SettingsTest.php
* | ||
* @var Comment | ||
*/ | ||
protected $commentStart; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be part of AbstractElement
? Seems it should be part of Comment
to me. Or is it because comments should be attached to an element? If so, maybe the attribute name could be clarified just a bit more? 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rvanlaak Indeed, the Comment starts at an element and ends at another one.
The node in the generated XML is named 'w:commentRangeStart and 'w:commentRangeEnd, maybe I could rename it to match this closer.
On the Comment itself, I'm keeping a reference back to the Element on which it starts/ends
private $startElement;
private $endElement;
I messed up the merge on this branch. I'm deleting this branch and pushing to a new one. |
i have trouble for using this feature (comment), i have couples of comments and want to attach it to single text. but always outputing one comment instead (i'm using loop for this). <?php
#.....
$purchaserName = $cell->addText("Purchaser Name");
$users = ['kampret'=>'Nice work!!', 'wakwauuu'=>'Awesome !!', 'oase'=>'Good Job!!'];
foreach($users as $user => $msg){
$cmnt = new \PhpOffice\PhpWord\Element\Comment($user, new \DateTime());
$cmnt->addText($msg, array('bold' => true));
$cmnt->setStartElement($purchaserName);
$cmnt->setEndElement($purchaserName);
$phpWord->addComment($cmnt);
} and sorry for my bad english 😄 . |
@hrydi I'm afraid I had not foreseen to add multiple comments on a same text element. Which is indeed wrong :-( |
@troosan thanks for the reply, |
@troosan hey hey, has there been any update on multiple comments? (it's hard to google this, the word "comment" pops up everywhere on the web!) Thanks! |
This will allow you to add comments in your generated documents.
To try it out, run the Sample_37_Comments.php
This will generate the following