This code is not working for me. I'm trying to replace a variable in my header. I need help.
public void header() throws Exception{
File doc = new File("C:/Users/Stacy/Documents/Thermal LESS.docx");
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(doc);
VariablePrepare.prepare(wordMLPackage);
HashMap<String, String> header = new HashMap<>();
header.put("LESS-Thermal-201908 ", "Stacy Header");
//headerPart.getDefaultHeader().getContent().add(header);
HashMap<String, String> footer = new HashMap<>();
footer.put(" ", "footer");
for (SectionWrapper section : wordMLPackage.getDocumentModel().getSections()) {
if (section.getHeaderFooterPolicy() != null) {
section.getHeaderFooterPolicy().getDefaultHeader().variableReplace(header);
section.getHeaderFooterPolicy().getDefaultFooter().variableReplace(footer);
wordMLPackage.save((new java.io.File("C:/Users/Stacy/Documents/Thermal LESSHeader.docx")));
}
}
}