public class FieldFormula extends Field
To learn more, visit the Working with Fields documentation article.
Remarks:
Calcualtes the result of an expression.
Examples:
Shows how to use the formula field to display the result of an equation.
Document doc = new Document();
// Use a field builder to construct a mathematical equation,
// then create a formula field to display the equation's result in the document.
FieldBuilder fieldBuilder = new FieldBuilder(FieldType.FIELD_FORMULA);
fieldBuilder.addArgument(2);
fieldBuilder.addArgument("*");
fieldBuilder.addArgument(5);
FieldFormula field = (FieldFormula) fieldBuilder.buildAndInsert(doc.getFirstSection().getBody().getFirstParagraph());
field.update();
Assert.assertEquals(field.getFieldCode(), " = 2 * 5 ");
Assert.assertEquals(field.getResult(), "10");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.FORMULA.docx");
getDisplayResult, getEnd, getFieldCode, getFieldCode, getFormat, getLocaleId, getResult, getSeparator, getStart, getType, isDirty, isDirty, isLocked, isLocked, needStoreOldResultNodes, remove, setLocaleId, setResult, unlink, update, update