@univerjs-pro/engine-pivot v0.5.0-beta.1 • Docs


Class: DataField

Represents a data field in a pivot table , it match the excel pivot cache field data structure.

Param

The unique identifier of the data field.

Param

The name of the data field. Almost is the row header of pivot table data source, the custom field such as calculated field or grouped field will have a different name.

Method

addRecord - Add a record to the data field.

Constructors

new DataField()

new DataField(
   id, 
   name, 
   hexCode): DataField

Parameters

ParameterType
idstring
namestring
hexCodestring

Returns

DataField

Defined in

field/data-field.ts:97

Properties

PropertyModifierTypeDefault valueDefined in
formatpublicstring''field/data-field.ts:69
hasBlankpublicbooleanfalsefield/data-field.ts:61
hasDatepublicbooleanfalsefield/data-field.ts:57
hasDecimalpublicbooleanfalsefield/data-field.ts:53
hasIntegerpublicbooleanfalsefield/data-field.ts:49
hasTextpublicbooleanfalsefield/data-field.ts:65
hexCodepublicstringundefinedfield/data-field.ts:24
idreadonlystringundefinedfield/data-field.ts:16
itemspublicstring[][]field/data-field.ts:36
itemTypespublicPivotDataFieldDataTypeEnum[][]field/data-field.ts:41
maxDatepublicnumberNumber.NaNfield/data-field.ts:81
maxNumberpublicnumberNumber.NaNfield/data-field.ts:73
minDatepublicnumberNumber.NaNfield/data-field.ts:85
minNumberpublicnumberNumber.NaNfield/data-field.ts:77
namepublicstringundefinedfield/data-field.ts:20
rangeKeypublicstringundefinedfield/data-field.ts:28
recordspublicIDataFieldValue[][]field/data-field.ts:32

Methods

addRecord()

addRecord(record, index): void

Parameters

ParameterTypeDescription
recordIDataFieldValueThe record to be added.
indexnumberThe index of the record.

Returns

void

Description

Add a record to the data field.

Defined in

field/data-field.ts:200


fromJSON()

fromJSON(data): void

Parameters

ParameterType
dataIDataFieldJSON

Returns

void

Defined in

field/data-field.ts:339


getFieldDataType()

getFieldDataType(): PivotDataFieldDataTypeEnum
  • if the field contains date value and blank only, the field data type is date. if the field contains number value and blank only, the field data type is number. otherwise, the field data type is text.

Returns

PivotDataFieldDataTypeEnum

the name of the data field.

Defined in

field/data-field.ts:140


getFieldInfo()

getFieldInfo(): IDataFieldInfo

Returns

IDataFieldInfo

The data field info.

Description

Get the data field info for pivot table, some properties are not included in the data field info because they are not necessary for the pivot table. only the import/export need them.

Defined in

field/data-field.ts:294


getformat()

getformat(): string

Returns

string

Defined in

field/data-field.ts:112


getId()

getId(): string

Returns

string

Defined in

field/data-field.ts:124


getIndexesByKey()

getIndexesByKey(key): number[]

Parameters

ParameterType
keystring

Returns

number[]

Defined in

field/data-field.ts:218


getItemKey()

getItemKey(index): string
  • Returns the key of the data field item. the key logic should be same with addRecord method.

Parameters

ParameterTypeDescription
indexnumberthe index of data records

Returns

string

The key of the data field item.

Defined in

field/data-field.ts:165


getItemSharedKey()

getItemSharedKey(key): string
  • Returns the shared key with the data field item, this can be combined in the tuple group with other data field item key to create a unique path.

Parameters

ParameterType
keystring

Returns

string

key with field and item info

Defined in

field/data-field.ts:156


getItemsMap()

getItemsMap(): Record<string, number>

Returns

Record<string, number>

Defined in

field/data-field.ts:286


getName()

getName(): string

Returns

string

Defined in

field/data-field.ts:128


getRangeKey()

getRangeKey(): string
  • Returns the name of the data field.

Returns

string

the range key of the data field.

Defined in

field/data-field.ts:108


getTypeByKey()

getTypeByKey(key): PivotDataFieldDataTypeEnum
  • get the type of date by key

Parameters

ParameterTypeDescription
keystringthe key of the data field item.

Returns

PivotDataFieldDataTypeEnum

the data type

Defined in

field/data-field.ts:181


getValue()

getValue(index): IDataFieldValue
  • Returns the value of the data field record

Parameters

ParameterTypeDescription
indexnumberThe index of the data field record.

Returns

IDataFieldValue

  • The value of the data field record.

Defined in

field/data-field.ts:190


reset()

reset(): void

Returns

void

Defined in

field/data-field.ts:365


setName()

setName(name): void

Parameters

ParameterType
namestring

Returns

void

Defined in

field/data-field.ts:132


setRangeKey()

setRangeKey(rangeKey): void
  • set the range key of the data field.

Parameters

ParameterTypeDescription
rangeKeystringthe range key of the data field.

Returns

void

Defined in

field/data-field.ts:120


toJSON()

toJSON(): IDataFieldJSON

Returns

IDataFieldJSON

Defined in

field/data-field.ts:309