antonmihaylov / OpenXmlTemplates

Word .docx templating system that is designer (no scripting tags) and server-friendly (no word installation required)
GNU Lesser General Public License v3.0
92 stars 25 forks source link

Content control style properties not applied. #35

Open agtenr opened 1 year ago

agtenr commented 1 year ago

I have a template that has a style applied in the Content Control Properties (Heading 1). However, when the text replacements are done, the styling is not there: image

Edit in Word

image

After the replacement:

image

Code:

// Replace standard content controls
var engine = new DefaultOpenXmlTemplateEngine();
var data = new
{
    meeting = new
    {
        title = "ICT Overleg",
        when = "24 feb. 2024",
        where = "Meeting room: Zolder"
    }
};
using var template = new TemplateDocument(wordDoc);
var src = new VariableSource(JsonConvert.SerializeObject(data));
engine.ReplaceAll(template, src);

Environment

antonmihaylov commented 1 year ago

Don't have time to fix this now, but feel free to open a PR if you see a way to solve it