Question

I am trying a hello world with Freemarker using xdocreport and put a condition in the docx file, but it does not work. I tried:

[#if name?has_content]
Sdfsdfsdf sdf sdf 
[/#if]

<#if name?has_content>
Sdfsdfsdf sdf sdf 
</#if>

[#if name??]
Sdfsdfsdf sdf sdf 
[/#if]

<#if name??>
Sdfsdfsdf sdf sdf 
</#if>

The replacing fields is working fine but not the conditional fields. The output is exactly the same as the input.

Was it helpful?

Solution

Your problem comes from with your docx which doesn't use mergefield. You must use mergefield to write any Freemarker directive, otherwise MS Word will escape your directive with XML characters (and your Freemarker directive will not work like your problem).

Note you have already posted this question question at https://code.google.com/p/xdocreport/issues/detail?id=285

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top