Main Content

mlreportgen.dom.Number Class

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

Style name, specified as a character vector or a string scalar. The style name is the name of a style specified in the style sheet of the document or document part to which this element is appended. The specified style defines the appearance of this element in the output document unless overridden by the formats specified by the Style property of this element. To learn more about using style sheets, see Use Style Sheet Styles.

Note

Microsoft® Word output ignores the style name.

Attributes:

NonCopyable
true

Data Types: char | string

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:

NonCopyable
true

Data Types: cell

Custom attributes of this document element, specified as an array of mlreportgen.dom.CustomAttribute objects. The custom attributes must be supported by the output format of the document element to which this object is appended.

Attributes:

NonCopyable
true

Parent of mlreportgen.dom.Number object, specified as a document element object. A document element must have only one parent.

Attributes:

SetAccess
private
NonCopyable
true

The class ignores this property.

Attributes:

SetAccess
private
NonCopyable
true

Tag for mlreportgen.dom.Number 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.Number 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

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