Main Content

mlreportgen.dom.NumberFormat Class

Namespace: mlreportgen.dom

Number formatting

Since R2021a

Description

Use an object of the mlreportgen.dom.NumberFormat class to specify the formatting of numbers in reports. To specify the formatting of one number, represent the number as an object of the mlreportgen.dom.Number class and include the NumberFormat object in the Style property of the Number object. To format all numbers in a document element, such as a paragraph, list, or table, include the NumberFormat object in the Style property of the object that represents the element.

The mlreportgen.dom.NumberFormat class is a handle class.

Class Attributes

ConstructOnLoad
true
HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

example

numberFormatObj = mlreportgen.dom.NumberFormat creates a NumberFormat object. Set the Value property to the format specification.

example

numberFormatObj = mlreportgen.dom.NumberFormat(value) creates a NumberFormat object and sets the Value property to the format specified by value.

Properties

expand all

Format specification, specified as a character vector or string scalar. The specification must be a valid format specification for the sprintf function and use one of these operators:

  • %f

  • %e

  • %E

  • %g

  • %G

Example: "%0.2f"

Attributes:

NonCopyable
true

Option to apply Value property to integers, specified as a numeric or logical 1 (true) or 0 (false). If true, the specified format will be applied to integers. If false, specified format will not be applied to integers.

Attributes:

NonCopyable
true

Data Types: logical

Tag for mlreportgen.dom.NumberFormat object, specified as a character vector or string scalar. The DOM API generates a session-unique tag as part of the creation of this object. The generated tag has the form CLASS:ID, where CLASS is the object class and ID is the value of the Id property of the object. Specify your own tag value to help you identify where to look when an issue occurs during document generation.

Attributes:

NonCopyable
true

Data Types: char | string

Object identifier for mlreportgen.dom.NumberFormat object, specified as a character vector or string scalar. The DOM API generates a session-unique identifier when it creates the document element object. You can specify your own value for Id.

Attributes:

NonCopyable
true

Data Types: char | string

Examples

collapse all

Represent a number as a Number object. Use a NumberFormat object to specify four digits of precision after the decimal point.

import mlreportgen.dom.*
  
rpt = Document("Report with NumberFormat","pdf");

n = Number(pi);
n.Style = [n.Style {NumberFormat("%0.4f")}];
append(rpt,n);
  
close(rpt);
rptview(rpt);

Version History

Introduced in R2021a