Main Content

mlreportgen.dom.NumberFormat class

Package: 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:

GetAccess
public
SetAccess
public
NonCopyable
true

Tag for this DOM API object, specified as a character vector or string scalar.

The DOM 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. Specifying your own tag value can help you to identify where an issue occurred during document generation.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

ID for this DOM API object, specified as a character vector or string scalar. The DOM generates a session-unique ID when it creates the document element. You can specify your own ID.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

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