legacy_number_format property

FieldOptions.legacy_number_format property

Gets or sets the value indicating whether legacy (early than AW 13.10) number format for fields is enabled or not.

@property
def legacy_number_format(self) -> bool:
    ...

@legacy_number_format.setter
def legacy_number_format(self, value: bool):
    ...

Remarks

When this property is set to True, template symbol “#” worked as in .net: Replaces the pound sign with the corresponding digit if one is present; otherwise, no symbols appears in the result string.

When this property is set to False, template symbol “#” works as MS Word: This format item specifies the requisite numeric places to display in the result. If the result does not include a digit in that place, MS Word displays a space. For example, { = 9 + 6 \# $### } displays $ 15.

The default value is False.

Examples

Shows how enable legacy number formatting for fields.

doc = aw.Document()
builder = aw.DocumentBuilder(doc)
field = builder.insert_field('= 2 + 3 \\# $##')
self.assertEqual('$ 5', field.result)
doc.field_options.legacy_number_format = True
field.update()
self.assertEqual('$5', field.result)

See Also