API Reference
@univerjs
@univerjs/core
classes
Range

@univerjs/core v0.1.17Docs


Class: Range

Beta

Access and modify spreadsheet ranges.

Remarks

A range can be a single cell in a sheet or a group of adjacent cells in a sheet.

Reference from: https://developers.google.com/apps-script/reference/spreadsheet/range (opens in a new tab)

Constructors

new Range()

new Range(
   workSheet, 
   range, 
   _deps): Range

Beta

Parameters

ParameterType
workSheetWorksheet
rangeIRange
_depsIRangeDependencies

Returns

Range

Defined in

submodules/univer/packages/core/src/sheets/range.ts:108 (opens in a new tab)

Methods

forEach()

forEach(action): void

Beta

Parameters

ParameterType
action(row, column) => void

Returns

void

Defined in

submodules/univer/packages/core/src/sheets/range.ts:734 (opens in a new tab)


getA1Notation()

getA1Notation(): string

Beta

Returns a string description of the range, in A1 notation.

Returns

string

The string description of the range in A1 notation.

Defined in

submodules/univer/packages/core/src/sheets/range.ts:249 (opens in a new tab)


getBackground()

getBackground(): string

Beta

Returns the background color of the top-left cell in the range (for example, '#ffffff').

Returns

string

— The color code of the background.

Defined in

submodules/univer/packages/core/src/sheets/range.ts:270 (opens in a new tab)


getBackgrounds()

getBackgrounds(): string[][]

Beta

Returns the background colors of the cells in the range (for example, '#ffffff').

Returns

string[][]

— A two-dimensional array of color codes of the backgrounds.

Defined in

submodules/univer/packages/core/src/sheets/range.ts:279 (opens in a new tab)


getBorder()

getBorder(): IBorderData

Beta

Returns the border info of the cells in the range.

Returns

IBorderData

Defined in

submodules/univer/packages/core/src/sheets/range.ts:486 (opens in a new tab)


getBorders()

getBorders(): IBorderData[][]

Beta

Returns

IBorderData[][]

Defined in

submodules/univer/packages/core/src/sheets/range.ts:490 (opens in a new tab)


getCell()

getCell(row, column): Range

Beta

Returns a given cell within a range.

The row and column here are relative to the range e.g. "B2:D4", getCell(0,0) in this code returns the cell at B2

Parameters

ParameterType
rownumber
columnnumber

Returns

Range

— A range containing a single cell at the specified coordinates.

Defined in

submodules/univer/packages/core/src/sheets/range.ts:296 (opens in a new tab)


getColumn()

getColumn(): number

Beta

Returns the starting column position for this range

Returns

number

— The range's starting column position in the spreadsheet.

Defined in

submodules/univer/packages/core/src/sheets/range.ts:313 (opens in a new tab)


getFontColor()

getFontColor(): string

Beta

Returns the font color of the cell in the top-left corner of the range, in CSS notation

Returns

string

Defined in

submodules/univer/packages/core/src/sheets/range.ts:361 (opens in a new tab)


getFontColors()

getFontColors(): string[][]

Beta

Returns the font colors of the cells in the range in CSS notation (such as '#ffffff' or 'white').

Returns

string[][]

Defined in

submodules/univer/packages/core/src/sheets/range.ts:368 (opens in a new tab)


getFontFamilies()

getFontFamilies(): string[][]

Beta

Returns the font families of the cells in the range.

Returns

string[][]

Defined in

submodules/univer/packages/core/src/sheets/range.ts:381 (opens in a new tab)


getFontFamily()

getFontFamily(): string

Beta

Returns the font family of the cell in the top-left corner of the range.

Returns

string

Defined in

submodules/univer/packages/core/src/sheets/range.ts:388 (opens in a new tab)


getFontSize()

getFontSize(): number

Beta

Returns the font size in point size of the cell in the top-left corner of the range.

Returns

number

Defined in

submodules/univer/packages/core/src/sheets/range.ts:461 (opens in a new tab)


getFontSizes()

getFontSizes(): number[][]

Beta

Returns the font sizes of the cells in the range.

Returns

number[][]

Defined in

submodules/univer/packages/core/src/sheets/range.ts:478 (opens in a new tab)


getFontStyle()

getFontStyle(): FontItalic

Beta

Returns the font style ('italic' or 'normal') of the cell in the top-left corner of the range.

Returns

FontItalic

Defined in

submodules/univer/packages/core/src/sheets/range.ts:497 (opens in a new tab)


getFontWeight()

getFontWeight(): FontWeight

Beta

Returns the font weight (normal/bold) of the cell in the top-left corner of the range. If the cell has rich text, the return value according to the textRuns of the rich text, when all styles of textRuns are bold, it will return FontWeight.BOLD, otherwise return FontWeight.NORMAL.

Returns

FontWeight

Defined in

submodules/univer/packages/core/src/sheets/range.ts:522 (opens in a new tab)


getGridId()

getGridId(): string

Beta

Returns the grid ID of the range's parent sheet.

Returns

string

Defined in

submodules/univer/packages/core/src/sheets/range.ts:544 (opens in a new tab)


getHeight()

getHeight(): number

Beta

Returns the height of the range.

Returns

number

Defined in

submodules/univer/packages/core/src/sheets/range.ts:551 (opens in a new tab)


getHorizontalAlignment()

getHorizontalAlignment(): HorizontalAlign

Beta

Returns the horizontal alignment of the text (left/center/right) of the cell in the top-left corner of the range.

Returns

HorizontalAlign

Defined in

submodules/univer/packages/core/src/sheets/range.ts:565 (opens in a new tab)


getHorizontalAlignments()

getHorizontalAlignments(): HorizontalAlign[][]

Beta

Returns the horizontal alignments of the cells in the range.

Returns

HorizontalAlign[][]

Defined in

submodules/univer/packages/core/src/sheets/range.ts:572 (opens in a new tab)


getLastColumn()

getLastColumn(): number

Beta

Returns the end column position.

Returns

number

Defined in

submodules/univer/packages/core/src/sheets/range.ts:579 (opens in a new tab)


getLastRow()

getLastRow(): number

Beta

Returns the end row position.

Returns

number

Defined in

submodules/univer/packages/core/src/sheets/range.ts:586 (opens in a new tab)


getMatrix()

getMatrix(): ObjectMatrix<Nullable<ICellData>>

Beta

get range matrix

Returns

ObjectMatrix<Nullable<ICellData>>

range matrix

Defined in

submodules/univer/packages/core/src/sheets/range.ts:209 (opens in a new tab)


getMatrixObject()

getMatrixObject(): ObjectMatrix<ICellData>

Beta

get range matrix object

Returns

ObjectMatrix<ICellData>

range matrix object

Defined in

submodules/univer/packages/core/src/sheets/range.ts:229 (opens in a new tab)


getNumColumns()

getNumColumns(): number

Beta

Returns the number of columns in this range.

Returns

number

Defined in

submodules/univer/packages/core/src/sheets/range.ts:593 (opens in a new tab)


getNumRows()

getNumRows(): number

Beta

Returns the number of rows in this range.

Returns

number

Defined in

submodules/univer/packages/core/src/sheets/range.ts:601 (opens in a new tab)


getObjectValue()

getObjectValue(options): Nullable<ICellData>

Beta

Returns the data of the object structure, and can set whether to bring styles

Parameters

ParameterType
optionsIValueOptionsType

Returns

Nullable<ICellData>

Defined in

submodules/univer/packages/core/src/sheets/range.ts:320 (opens in a new tab)


getObjectValues()

getObjectValues(options): IObjectMatrixPrimitiveType<Nullable<ICellData>>

Beta

Returns the data of the object structure, and can set whether to bring styles

Parameters

ParameterTypeDescription
optionsIValueOptionsTypeset whether to include style

Returns

IObjectMatrixPrimitiveType<Nullable<ICellData>>

Returns a value in object format

Defined in

submodules/univer/packages/core/src/sheets/range.ts:330 (opens in a new tab)


getOverline()

getOverline(): ITextDecoration

Beta

Returns the overline of the cells in the range.

Returns

ITextDecoration

Defined in

submodules/univer/packages/core/src/sheets/range.ts:428 (opens in a new tab)


getOverlines()

getOverlines(): ITextDecoration[][]

Beta

Returns the overlines of the cells in the range.

Returns

ITextDecoration[][]

Defined in

submodules/univer/packages/core/src/sheets/range.ts:421 (opens in a new tab)


getRangeData()

getRangeData(): IRange

Beta

get current range data

Returns

IRange

current range

Defined in

submodules/univer/packages/core/src/sheets/range.ts:162 (opens in a new tab)


getRichTextValue()

getRichTextValue(): Nullable<"" | IDocumentData>

Beta

Returns the Rich Text value for the top left cell of the range, or null if the cell value is not text.

Returns

Nullable<"" | IDocumentData>

Defined in

submodules/univer/packages/core/src/sheets/range.ts:609 (opens in a new tab)


getRichTextValues()

getRichTextValues(): Nullable<"" | IDocumentData>[][]

Beta

Returns the Rich Text values for the cells in the range.

Returns

Nullable<"" | IDocumentData>[][]

Defined in

submodules/univer/packages/core/src/sheets/range.ts:616 (opens in a new tab)


getRowIndex()

getRowIndex(): number

Beta

Returns the row position for this range.

Returns

number

Defined in

submodules/univer/packages/core/src/sheets/range.ts:623 (opens in a new tab)


getSheet()

getSheet(): Worksheet

Beta

Returns the sheet this range belongs to.

Returns

Worksheet

Defined in

submodules/univer/packages/core/src/sheets/range.ts:630 (opens in a new tab)


getStrikeThrough()

getStrikeThrough(): ITextDecoration

Beta

Returns the strikeThrough of the cells in the range.

Returns

ITextDecoration

Defined in

submodules/univer/packages/core/src/sheets/range.ts:435 (opens in a new tab)


getTextDirection()

getTextDirection(): number

Beta

Returns the text direction for the top left cell of the range.

Returns

number

Defined in

submodules/univer/packages/core/src/sheets/range.ts:637 (opens in a new tab)


getTextDirections()

getTextDirections(): number[][]

Beta

Returns the text directions for the cells in the range.

Returns

number[][]

Defined in

submodules/univer/packages/core/src/sheets/range.ts:644 (opens in a new tab)


getTextRotation()

getTextRotation(): ITextRotation

Beta

Returns the text rotation settings for the top left cell of the range.

Returns

ITextRotation

Defined in

submodules/univer/packages/core/src/sheets/range.ts:652 (opens in a new tab)


getTextRotations()

getTextRotations(): ITextRotation[][]

Beta

Returns the text rotation settings for the cells in the range.

Returns

ITextRotation[][]

Defined in

submodules/univer/packages/core/src/sheets/range.ts:660 (opens in a new tab)


getTextStyle()

getTextStyle(): Nullable<IStyleData>

Beta

Returns the text style for the top left cell of the range.

Returns

Nullable<IStyleData>

Defined in

submodules/univer/packages/core/src/sheets/range.ts:667 (opens in a new tab)


getTextStyles()

getTextStyles(): Nullable<IStyleData>[][]

Beta

Returns the text styles for the cells in the range.

Returns

Nullable<IStyleData>[][]

Defined in

submodules/univer/packages/core/src/sheets/range.ts:674 (opens in a new tab)


getUnderline()

getUnderline(): ITextDecoration

Beta

Returns the underline of the cells in the range.

Returns

ITextDecoration

Defined in

submodules/univer/packages/core/src/sheets/range.ts:402 (opens in a new tab)


getUnderlines()

getUnderlines(): ITextDecoration[][]

Beta

Returns the underlines of the cells in the range.

Returns

ITextDecoration[][]

Defined in

submodules/univer/packages/core/src/sheets/range.ts:395 (opens in a new tab)


getValue()

getValue(): Nullable<ICellData>

Beta

Returns the value of the top-left cell in the range. The value may be of type Number, Boolean, Date, or String depending on the value of the cell. Empty cells return an empty string.

Returns

Nullable<ICellData>

The value in this cell

Defined in

submodules/univer/packages/core/src/sheets/range.ts:171 (opens in a new tab)


getValues()

getValues(): Nullable<ICellData>[][]

Beta

Returns the rectangular grid of values for this range.

Returns a two-dimensional array of values, indexed by row, then by column. The values may be of type Number, Boolean, Date, or String, depending on the value of the cell. Empty cells are represented by an empty string in the array. Remember that while a range index starts at 0, 0, same as the JavaScript array is indexed from [0][0].

In web apps, a Date value isn't a legal parameter. getValues() fails to return data to a web app if the range contains a cell with a Date value. Instead, transform all the values retrieved from the sheet to a supported JavaScript primitive like a Number, Boolean, or String.

Returns

Nullable<ICellData>[][]

A two-dimensional array of values.

Defined in

submodules/univer/packages/core/src/sheets/range.ts:188 (opens in a new tab)


getVerticalAlignment()

getVerticalAlignment(): VerticalAlign

Beta

Returns the vertical alignment (top/middle/bottom) of the cell in the top-left corner of the range.

Returns

VerticalAlign

Defined in

submodules/univer/packages/core/src/sheets/range.ts:682 (opens in a new tab)


getVerticalAlignments()

getVerticalAlignments(): VerticalAlign[][]

Beta

Returns the vertical alignments of the cells in the range.

Returns

VerticalAlign[][]

Defined in

submodules/univer/packages/core/src/sheets/range.ts:689 (opens in a new tab)


getWidth()

getWidth(): number

Beta

Returns the width of the range in columns.

Returns

number

Defined in

submodules/univer/packages/core/src/sheets/range.ts:696 (opens in a new tab)


getWrap()

getWrap(): BooleanNumber

Beta

Returns whether the text in the cell wraps.

Returns

BooleanNumber

Defined in

submodules/univer/packages/core/src/sheets/range.ts:709 (opens in a new tab)


getWrapStrategies()

getWrapStrategies(): WrapStrategy[][]

Beta

Returns the text wrapping strategies for the cells in the range.

Returns

WrapStrategy[][]

Defined in

submodules/univer/packages/core/src/sheets/range.ts:723 (opens in a new tab)


getWrapStrategy()

getWrapStrategy(): WrapStrategy

Beta

Returns the text wrapping strategy for the top left cell of the range.

Returns

WrapStrategy

Defined in

submodules/univer/packages/core/src/sheets/range.ts:730 (opens in a new tab)


getWraps()

getWraps(): BooleanNumber[][]

Beta

Returns whether the text in the cells wrap.

Returns

BooleanNumber[][]

Defined in

submodules/univer/packages/core/src/sheets/range.ts:716 (opens in a new tab)


foreach()

static foreach(range, action): void

Beta

Parameters

ParameterType
rangeIRange
action(row, column) => void

Returns

void

Defined in

submodules/univer/packages/core/src/sheets/range.ts:117 (opens in a new tab)


transformRange()

static transformRange(range, worksheet): IRange

Beta

Parameters

ParameterType
rangeIRange
worksheetWorksheet

Returns

IRange

Defined in

submodules/univer/packages/core/src/sheets/range.ts:126 (opens in a new tab)


Copyright © 2021-2024 DreamNum Co,Ltd. All Rights Reserved.