-
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
Changing document properties when using Template Processor or loadTemplate() #908
Comments
bump, is it possible to modify document properties? |
This is currently not possible, the TemplateProcessor only allows you to change the body and the header of the document |
@troosan If it is not possible, with this problem https://github.com/PHPOffice/PHPWord/issues/991, how can I change docx settings? |
I guess your best option is to use applyXslStyleSheet(...) |
@icy2003 thanks. |
@troosan thx |
@icy2003 indeed, I was thinking to change this method to be more generic instead of supporting only this feature. to be followed! |
@troosan |
@troosan can you link to where this was integrated. I am looking into setting custom document properties and templateprocessor does not seem to support it. :( @icy2003 your link (https://github.com/icy2003/icy2003_php/blob/master/iexts/phpword/TemplateProcessor.php) |
@chrisribe emmmmm……I put it in another folder, now it is https://github.com/icy2003/php/blob/master/src/iexts/PhpOffice/PhpWord/TemplateProcessor.php |
Thanks ! But it seems to have changed a lot or is out of date compared to the current one on the develop branch. Where you able to set the document properties via TemplateProcessor ? An how ? |
@chrisribe by using regular expression, setting operate function is only setIsUpdateFields, others are some operations for generating blocks |
@chrisribe I provide a function for setting xml part,you can match the string for your own function, the way I wrote setIsUpdateFields was by comparing the xml I changed before and the after,maybe it's not a good way, but it runs well |
If I understand correctly you load the template then replace xml after... It is just not clear how you can proceed to load your template, set your custom property value then save. I am looking to perform this on the template then save,
Sorry I do not have any experience parsing docx xml values and their values relative to the docx format. |
@chrisribe sorry for that......I don't know about custom property until you ask me......all I know is to use xdebug and run and test and change word document and unzip and compare xml again and again |
Ah ok I get it. That allows you to figure out what is what and how the xml stucture changes based on set values in the docx. So when using your lib you never set things like "setCompany" etc ? The code is more for debug purposes ? Was assuming you could set properties, since this issue is about "document properties". |
@chrisribe setIsUpdateFields |
@icy2003 Only has a true/false parameter, that's why I am having a hard time decoding your code. _tempDocumentSettingPart == target template (init on construct). tempDocumentMainPart == seems to be init via setMain That's why I wanted a pseudo example on how you use your lib :) |
@chrisribe
php:
$array is come from iWorksheet::rangeToArray which is from Worksheet::rangeToArray,I wrote templateProcessor because I need convert Excel to Word table, you can find the differences easily beacause I named them the similar namespace between phpoffice and my lib |
@chrisribe you may use cloneRow to clone a table in templateProcessor from phpoffice, but it cannot help me to convert any, I mean any Excel table to word table, and I need to bring styles from excel to word, and, also the merge cell parts!! |
@icy2003 thanks for taking the time to explain, I get what you are doing now. |
@chrisribe may help you with my lib |
@chrisribe if you want to match yourself, see this: |
Any update on this? I am trying to change the word document title on a document generated through TemplateProcessor, is there a way of doing this?
|
I'm also interested in this |
Does anyone have idea how to set new document properties (setCreator, setCompany, setTitle) when template is loaded and processed? I got document properties to work fine when creating new document but can't get it to work when using loadTemplate(). Thanks!
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: