Main Content

mlreportgen.dom.Number class

Package: mlreportgen.dom

Number to include as formatted text in a document

Since R2021a

Description

Use an object of the mlreportgen.dom.Number class to convert a number to formatted text that you can include in a document.

The conversion uses the first of these format specifications that it finds:

  1. The specification in an mlreportgen.dom.NumberFormat object in the Style property of the Number object

  2. The specification in a NumberFormat object in the Style property of an element, such as a paragraph, list, or table, that contains the Number object

  3. The default specification set by mlreportgen.dom.setDefaultNumberFormat

If the conversion does not find a format specification, the conversion uses the maximum number of digits needed to represent the number accurately.

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

Class Attributes

ConstructOnLoad
true
HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

numberObj = mlreportgen.dom.Number() creates an empty Number object. Use the Value property to specify a number to convert to formatted text.

example

numberObj = mlreportgen.dom.Number(value) creates a Number object with the Value property set to value.

numberObj = mlreportgen.dom.Number(value,stylename) creates a Number object with the Value property set to value and the StyleName property set to stylename.

Properties

expand all

Number to convert to formatted text, specified as a scalar. Complex numbers are not supported.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Name of the stylesheet-defined style for this number when converted to text, specified as a character vector or string scalar.

The style specified by the StyleName property must be defined in the stylesheet of the document or document part to which this Number object is appended. The specified style defines the appearance of the textual representation of the number in the output document. Formats specified by the Style property override formats defined by the stylesheet.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Formats that define the style of this number when converted to text, specified as a cell array of DOM format objects. Use an mlreportgen.dom.NumberFormat object to specify the precision of the converted number. The formats override the corresponding formats defined by the stylesheet style specified by the StyleName property.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Custom attributes of the document element that contains the converted number, specified as a cell array of mlreportgen.dom.CustomAttribute objects. The output format must support the custom attributes.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Parent of this number object, specified as a document element object.

Attributes:

GetAccess
public
SetAccess
private
NonCopyable
true

This property is ignored.

Attributes:

GetAccess
public
SetAccess
private
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

Methods

expand all

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