I have had a good look around but can't seem to find a way to programmatically update a table of contents. The only information I came across is to set a flag which forces an update on open, which does the job but due to the warning message it isn't as clean as I'd like. The documents I'm generating will be sent around to many people and I don't want to cause confusion with the warning message they'd be presented with. The code I'm using to do this is:
Using java Syntax Highlighting
DocumentSettingsPart dsp = template.getMainDocumentPart().getDocumentSettingsPart();
CTSettings objCTSettings = dsp.getJaxbElement();
BooleanDefaultTrue b = new BooleanDefaultTrue();
b.setVal(true);
objCTSettings.setUpdateFields(b);
dsp.setJaxbElement(objCTSettings);
template.getMainDocumentPart().addTargetPart(dsp);
CTSettings objCTSettings = dsp.getJaxbElement();
BooleanDefaultTrue b = new BooleanDefaultTrue();
b.setVal(true);
objCTSettings.setUpdateFields(b);
dsp.setJaxbElement(objCTSettings);
template.getMainDocumentPart().addTargetPart(dsp);
Parsed in 0.015 seconds, using GeSHi 1.0.8.4
is there something else I can do?
cheers,
graham