-
Notifications
You must be signed in to change notification settings - Fork 22
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
Non-M2Doc fields are replaced by (typically wrong) fixed values during generation #466
Comments
There are some known issues with fields after generation. Did you try to set the Let me know if it helps. |
I forgot to mention it here again, but as stated in my comment to #377: No, the UpdateFields option does not help. If I interpret the code in 2027b6e correctly, then the touched fields are marked as "dirty" to notify Word (or Apache POI? To make sure they are interpreted?). But in this case the fields are replaced by static text during generation, they are no fields anymore, so this is something different, isn't it? |
@ylussaud From experience with further reporting work (longer reports) it seems that only the caption fields of the last for loop survive (i.e. stay as Word fields), the caption fields in the previous loops are all replaced by fixed values. |
That will help thank you. |
Hi @ylussaud, |
You can have a look at the following:
One way to investigate:
You will get unrelated changes. You can remove them form the expected folder (first document) and zip the folder to check is you still have your fields. At some point you should be left with the important changes and then need to modify M2Doc to produce them. Also M2Doc rely on the Apache POI API but it can be also useful to get the OOXML API directly some time. For instance with:
Then the API follows the XML document structure. But first try to use an API at POI level to minimize headaches ;) If you have any progress let me know. And of course if you have a patch please open a pull request. I will be glade to review it. |
I tested with the master branch of M2Doc and I'm not reproducing this issue. But I don't see a for loop in the template you attached so maybe your template doesn't show the issue or this issue has been fixed. Let me know if this issue is still relevant and if you have an idea to reproduce it. |
Note: I've added my findings already to #377, but they may not have been recognized on that already closed issue.
I'm submitting a...
Current behavior
In my template, the field for the filename ({ FILENAME * MERGEFORMAT }) in the footer is replaced during generation by the actual value - by the template filename, not the filename of the generated document.
Expected behavior
Expectation is that the field stays intact without being replaced by a value by M2Doc (it's not starting with "m:", so M2Doc shouldn't alter it).
Minimal reproduction of the problem with instructions
Use the attached template file to generate the file (generated file also attached).
I played a bit around (we are using M2Doc 3.2.0 programmatically, but normal UI does show the same behaviour, below files are from that one) and saw that it very much depends on the template file itself:
Files:
M2Doc_PHA_Landscape.docx
M2Doc_PHA_Landscape.generated.docx
What is the motivation / use case for changing the behavior?
Apart from this example, we also see cases of replaced figure numbers etc. - a big problem, as these figure numbers are then all wrong and would have to be replaced manually by fields again after generation.
Environment
The text was updated successfully, but these errors were encountered: