Range
This topic describes the API operations that are related to the Range object of table documents.
Range
Obtains a cell, a row, a column, or a range that contains one or more contiguous blocks of cells.
Syntax
expression.Rangeexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1'); }
Methods
Range.Item()
You can obtain the location of a cell in a specific range by using the Item() method.
Syntax
expression.Range.Item({ RowIndex, ColumnIndex })expression: the application object of the document type.
Parameters
Property
Data type
Required
Description
RowIndex
Number
Yes
The index of the subrange or the relative row number of the cell to return.
If the
ColumnIndexparameter is specified, this parameter specifies the relative row number of the cell to return.If the
ColumnIndexparameter is not specified, this parameter specifies the index of the subrange.
ColumnIndex
Number
No
The relative column number of the cell to return.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:D2'); // Obtain the relative location of a cell in the range. In this example, B2 is used. const item1 = await range.Item(2, 2); await item1.Select(); }
Range.Activate()
You can activate a range by using the Activate() method.
Syntax
expression.Range.Activate()expression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1'); // Activate range A1. range.Activate(); }
Range.AddComment()
You can add a comment to a range by using the AddComment() method.
Syntax:
expression.Range.AddComment({ Text })expression: the application object of the document type.
Parameter
Property
Data type
Required
Description
Text
String
No
The text of the comment.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1'); // Add a comment to range A1. range.AddComment('Aliyun'); }
Range.Address()
You can obtain a String value that indicates the range reference in macro language by using the Address() method.
Syntax
expression.Range.Address({ RowAbsolute, ColumnAbsolute, ReferenceStyle, External, RelativeTo })expression: the application object of the document type.
Parameters
Property
Data type
Required
Description
RowAbsolute
Boolean
No
Specifies whether to return the row part of the reference as an absolute reference. Valid values:
true (default)
false
ColumnAbsolute
Boolean
No
Specifies whether to return the column part of the reference as an absolute reference. Valid values:
true (default)
false
ReferenceStyle
Enum
No
The reference style. Default value: xlA1.
External
Boolean
No
Specifies whether to return an external reference or a local reference. Valid values:
false (default): returns a local reference.
true: returns an external reference.
RelativeTo
Range
No
The Range object that defines the start point.
If the
RowAbsoluteandColumnAbsoluteparameters are set tofalseand theReferenceStyleparameter is set toxlR1C1, a start point must be included.Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1'); // Obtain the String value that indicates the range reference in macro language. const address1 = await range.Address(); console.log('address1:', address1); const address2 = await range.Address(false, false); console.log('address2:', address2); const address3 = await range.Address(true, true, -4150); console.log('address3:', address3); }
Range.AutoFill()
You can perform an autofill on the cells in a range by using the AutoFill() method.
Syntax
expression.Range.AutoFill({ Destination, Type })expression: the application object of the document type.
Parameters
Property
Data type
Required
Description
Destination
Range
No
The range in which the cells are to be filled. The destination range must include the source range.
Type
Enum
No
The fill type. Default value:
Enum.XlAutoFillType.xlFillDefault.Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:A2'); // Specify the cells to be filled. const fillRange = await app.Range('A1:A20'); // Perform autofill on the specified cells. await range.AutoFill(fillRange); }
Range.ClearComments()
You can clear the comments from a range by using the ClearComments() method.
Syntax
expression.Range.ClearComments()expression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:A2'); // Clear the comments from the range. await range.ClearComments(); }
Range.ClearContents()
You can clear the contents from a range by using the ClearContents() method.
Syntax
expression.Range.ClearContents()expression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:A2'); // Clear the contents from the range. await range.ClearContents(); }
Range.Contain()
You can check whether two Range objects overlap by using the Contain() method.
Syntax
expression.Range.Contain({ Range })expression: the application object of the document type.
Parameter
Property
Data type
Required
Description
Range
Range
Yes
The other Range object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:D2'); // Obtain the other Range object. const newRange = await app.Range('A1:B4'); // Check whether the two ranges overlap. const contain = await range.Contain(newRange); console.log(contain); }
Range.Merge()
You can merge cells in a range by using the Merge() method.
Syntax
expression.Range.Merge({ Across })expression: the application object of the document type.
Parameter
Property
Data type
Required
Description
Across
Boolean
Yes
Specifies whether to merge cells in each row of the range as one cell. Valid values:
false (default)
true
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:D2'); // Merge cells. await range.Merge(); }
Range.UnMerge()
You can unmerge cells in a range by using the UnMerge() method.
Syntax
expression.Range.UnMerge({ CancelCenter })expression: the application object of the document type.
Parameter
Property
Data type
Required
Description
CancelCenter
Boolean
No
Specifies whether to center the merged cells in the range. Valid values:
false (default)
true
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:D2'); setTimeout(async () => { // Unmerge the cells. await range.UnMerge(); }, 3000); }
Range.Offset()
You can move the contents of a range by using the Offset() method.
Syntax
expression.Range.Offset({ RowOffset, ColumnOffset })expression: the application object of the document type.
Parameters
Property
Data type
Required
Description
RowOffset
Number
No
The number of rows by which the contents of the range are to be moved. Valid values:
Positive integers: move the contents of the range downward.
Negative integers: move the contents of the range upward.
0 (default): does not move the contents of the range.
ColumnOffset
Number
No
The number of columns by which the contents of the range are to be moved. Valid values:
Positive integers: move the contents of the range rightward.
Negative integers: move the contents of the range leftward.
0 (default): does not move the contents of the range.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:D2'); await range.Select(); // Move the contents of the range. const newRange = await range.Offset(2, 2); await newRange.Select(); }
Range.Select()
You can select an active cell in a range by using the Select() method.
Syntax
expression.Range.Select()expression: the application object of the document type.
Parameters
Property
Data type
Required
Description
ActiveCell
Object
No
The active cell to be selected in the range. Format:
{row: number, col: number}.row: the row number of the active cell to be selected in the range.
col: the column number of the active cell to be selected in the range.
NoteIf the row or column number exceeds the range, the first cell in the range is selected.
Twinkle
Boolean
No
Specifies whether to display the flashing animation. Valid values:
false (default)
true
Examples
Example 1:
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1'); // Select range A1. range.Select(); // Select range B1:D2 after 5,000 milliseconds. setTimeout(async () => { const newRange = await app.Range('B1:D2'); newRange.Select(); }, 5000); }Example 2
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1'); // Select range A1 and display flashing animation. range.Select(null, true); // Select range B1:D2 after 5,000 milliseconds and select the cell in the second column and second row of B1:D2 as the active cell. setTimeout(async () => { const newRange = await app.Range('B1:D2'); newRange.Select({row: 2, col: 2}, true); }, 5000); }
Range.ToImageDataURL()
You can export a range as an image by using the ToImageDataURL() method.
Syntax
expression.Range.ToImageDataURL()expression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:D2'); // Export the range as an image. const img = await range.ToImageDataURL(); console.log(img); }
Range.Insert()
You can add one or more rows, columns, or cells into a range by using the Insert() method.
Syntax
expression.Range.Insert()expression: the application object of the document type.
Examples
Add one or more rows
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('B5:D10'); // Select all rows in the range and add one or more rows above the range. await range.EntireRow.Insert(); }Add one or more columns
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('B5:D10'); // Select all columns in the range and add one or more columns to the left of the range. await range.EntireColumn.Insert(); }
Range.PasteSpecial()
You can paste a Range object that is copied into the destination range by using the PasteSpecial() method.
Only JavaScript SDK V1.1.12 and later support this feature.
Syntax
expression.Range.PasteSpecial()expression: the application object of the document type.
Parameters
Property
Data type
Required
Description
Paste
Enum.XlPasteType
No
The paste type. For more information, see the XlPasteType section of the "Table" topic.
Operation
Enum.XlPasteSpecialOperation
No
The paste operation.
SkipBlanks
Boolean
No
Specifies whether to paste blank cells in the source range on the clipboard into the destination range. Valid values:
false (default)
true
Transpose
Boolean
No
Specifies whether to transpose rows and columns of the source range when the range is pasted. Valid values:
false (default)
true
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Selection // Paste the Range object into the destination range. await range.PasteSpecial(); }
Range.Find()
You can search for data in a range by using the Find() method. The method returns a Range object that can use Range-related properties and methods.
Syntax
expression.Range.Find({ What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte, SearchFormat })expression: the application object of the document type.
Parameters
Property
Data type
Required
Description
What
String
Yes
The data to be searched for.
After
Range
No
The cell after which the search starts. If you do not specify this parameter, the search starts after the cell in the upper-left corner of the range.
LookIn
Enum
No
The type of the search. Default value:
Enum.LookIn.etSmart. For more information, see the LookIn section of the "Table" topic.LookAt
Enum
No
Specifies whether to match the entire text or a part of text. Default value:
Enum.LookAt.etPart. For more information, see the LookAt section of the "Table" topic.SearchOrder
Enum
No
The order of the search. Default value:
Enum.SearchOrder.etByRows. For more information, see the SearchOrder section of the "Table" topic.SearchDirection
Enum
No
The direction of the search. Default value:
Enum.SearchDirection.etNext. For more information, see the SearchDirection section of the "Table" topic.MatchCase
Boolean
No
Specifies whether the search is case-sensitive. Valid values:
false (default)
true
MatchByte
Boolean
No
Specifies whether double-byte characters match only double-byte characters. Valid values:
true: Double-byte characters match only double-byte characters.
false (default): Double-byte characters can match their single-byte equivalents.
SearchFormat
Object
No
The format of the search.
Example
//@file=base.xlsx async function example() { await instance.ready(); const app = instance.Application; // The cell object that contains all cells. const cells = await app.Cells; // Search for a cell. let range = await cells.Find('123'); // Search for the next cell. range = await cells.Find('123', range); // Select the cells that are found. await range.Select(); }
Range.FindAll()
You can search for all specific data in a range by using the FindAll() method. The method returns an array that contains the addresses of all matched cells.
Syntax
expression.Range.FindAll({ What, LookIn, LookAt, SearchOrder, MatchCase, MatchByte, SearchRange })expression: the application object of the document type.
Parameters
Property
Data type
Required
Description
What
String
Yes
The data to be searched for.
LookIn
Enum
No
The type of the search. Default value:
Enum.LookIn.etSmart. For more information, see the LookIn section of the "Table" topic.LookAt
Enum
No
Specifies whether to match the entire text or a part of text. Default value:
Enum.LookAt.etPart. For more information, see the LookAt section of the "Table" topic.SearchOrder
Enum
No
The order of the search. Default value:
Enum.SearchOrder.etByRows. For more information, see the SearchOrder section of the "Table" topic.MatchCase
Boolean
No
Specifies whether the search is case-sensitive. Valid values:
false (default)
true
MatchByte
Boolean
No
Specifies whether double-byte characters match only double-byte characters. Valid values:
true: Double-byte characters match only double-byte characters.
false (default): Double-byte characters can match their single-byte equivalents.
SearchRange
Enum
No
The scope of the search. Default value:
Enum.FindScope.etSheet. For more information, see the FindScope section of the "Table" topic.Example
//@file=base.xlsx async function example() { await instance.ready(); const app = instance.Application; // The cell object that contains all cells. const cells = await app.Cells; // Search for cells and return the addresses of all cells that contain "123". let results = await cells.FindAll('123'); // The first cell that is found. const range = await app.Range(results[0]); // Select the cell. await range.Select(); }
Range.Copy()
You can copy the contents of a range to the clipboard by using the Copy() method.
Only JavaScript SDK V1.1.19 and later support this feature.
Syntax
expression.Range.Copy()expression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:D2'); // Copy the contents of the range to the clipboard. await range.Copy(); // The contents of the range are copied to the clipboard and can be pasted by pressing Ctrl + V. }
Range.RemoveDuplicates()
You can remove duplicate values from a range by using the RemoveDuplicates() method.
Only JavaScript SDK V1.1.19 and later support this feature.
Syntax
expression.Range.RemoveDuplicates({ Columns, Header })expression: the application object of the document type.
Parameters
Property | Data type | Required | Description |
Columns |
| Yes | The array of indexes of columns that contain duplicate values. |
Header | Enum | No | Specifies whether the first row contains header information. Default value: xlNo. If you want to specify a header for a table, set this parameter to xlGuess. |
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:D2'); // Remove duplicate values. await range.RemoveDuplicates([1,2]); }
Properties
Range.Cells
You can obtain a cell in a range by using the Cells property.
Syntax
expression.Range.Cellsexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:B2'); // Obtain all cells. const cells = await range.Cells; // Obtain the first cell. const cell = await cells.Item(1); window.cells = cells; // Select the cell. await cell.Select(); }
Range.Column
You can obtain the number of the first column in a range by using the Column property.
Syntax
expression.Range.Columnexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:B2'); // Obtain the number of the first column in the range. const column = await range.Column; console.log(column); }
Range.ColumnEnd
You can obtain the number of the last column in a range by using the ColumnEnd property.
Syntax
expression.Range.ColumnEndexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:B2'); // Obtain the number of the last column in the range. const columnEnd = await range.ColumnEnd; console.log(columnEnd); }
Range.ColumnWidth
You can specify the width of a range by using the ColumnWidth property.
Syntax
expression.Range.ColumnWidthexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:B2'); // Specify the width of the range. Unit: pixel. range.ColumnWidth = 30; }
Range.Columns
You can obtain columns in a range by using the Columns property.
Syntax
expression.Range.Columnsexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:B2'); // Obtain all columns in the range. const columns = await range.Columns; // Obtain the second column in the range. const column = await columns.Item(2); // Select the column. await column.Select(); }
Range.Count
You can obtain the number of cells in a range by using the Count property.
Syntax
expression.Range.Countexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:B2'); // Obtain the number of cells in the range. const count = await range.Count; console.log(count); }
Range.EntireColumn
You can obtain the entire column that contains a range by using the EntireColumn property.
Syntax
expression.Range.EntireColumnexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1'); // Obtain the entire column that contains the range. const entireColumn = range.EntireColumn; // Select the column. await entireColumn.Select(); }
Range.EntireRow
You can obtain the entire row that contains a range by using the EntireRow property.
Syntax
expression.Range.EntireRowexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1'); // Obtain the entire row that contains the range. const entireRow = range.EntireRow; // Select the row. await entireRow.Select(); }
Range.Formula
You can represent the implicitly intersecting formula of an object in a range in A1-style notation by using the Formula property.
Syntax
expression.Range.Formulaexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A2'); // Specify the formula A2=A1 + B1. range.Formula = '=A1+B1'; }
Range.FormulaArray
You can specify or obtain an array formula of a range by using the FormulaArray property.
Syntax
expression.Range.FormulaArrayexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A2:B2'); // Specify the formula =Sum(A1:B1) in cells A2:B2. range.FormulaArray = '=Sum(A1:B1)'; // Obtain the formula. const formulaArray = await range.FormulaArray; console.log(formulaArray); }
Range.Hidden
You can specify whether to hide the entire row or column that contains a range by using the Hidden property.
Syntax
expression.Range.Hidden = Booleanexpression: the application object of the document type.
If you specify
trueforBoolean, the row or column is hidden. If you specifyfalsefor Boolean, the row or column is displayed.Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1'); // Obtain the entire column that contains the range. const entireColumn = range.EntireColumn; // Hide the column. entireColumn.Hidden = true; }
Range.HorizontalAlignment
You can specify and obtain the horizontal alignment for a range by using the HorizontalAlignment property. For more information, see the XlHAlign section of the "Table" topic.
Syntax
expression.Range.HorizontalAlignmentexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1'); // Specify center alignment. range.HorizontalAlignment = await app.Enum.XlHAlign.xlHAlignCenter; setTimeout(async () => { // Obtain the alignment after 3,000 milliseconds. const horizontalAlignment = await range.HorizontalAlignment; console.log(horizontalAlignment); }, 3000); }
Range.Left
You can obtain the distance from the left edge of column A to the left edge of a range by using the Left property.
Syntax
expression.Range.Leftexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('B2'); // Specify center alignment. range.HorizontalAlignment = await app.Enum.XlHAlign.xlHAlignCenter; // Obtain the distance from the left edge of column A to the left edge of B2. const left = await range.Left; console.log(left); }
Range.MergeArea
You can obtain the merged range of cells by using the MergeArea property.
Syntax
expression.Range.MergeAreaexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:D2'); // Merge cells. await range.Merge(); setTimeout(async () => { // Obtain the merged range of cells after 5,000 milliseconds. const mergeArea = await range.MergeArea; mergeArea.Select(); }, 5000); }
Range.MergeCells
You can check whether a range contains merged cells by using the MergeCells property.
Syntax
expression.Range.MergeCellsexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:D2'); // Merge cells. await range.Merge(); // Check whether the range contains merged cells. const mergeCells = await range.MergeCells; console.log(mergeCells); }
Range.Row
You can obtain the number of the first row in a range by using the Row property.
Syntax
expression.Range.Rowexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:B2'); // Obtain the number of the first row in the range. const row = await range.Row; console.log(row); }
Range.RowEnd
You can obtain the number of the last row in a range by using the RowEnd property.
Syntax
expression.Range.RowEndexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:B2'); // Obtain the number of the last row in the range. const rowEnd = await range.RowEnd; console.log(rowEnd); }
Range.RowHeight
You can specify the height of a range by using the RowHeight property.
Syntax
expression.Range.RowHeightexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:B2'); // Specify the height of the range. Unit: pixel. range.RowHeight = 100; }
Range.Rows
You can obtain the rows in a range by using the Rows property.
Syntax
expression.Range.Rowsexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:B2'); // Obtain all rows. const rows = await range.Rows; // Obtain the second row. const row = await rows.Item(2); // Select the row. await row.Select(); }
Range.Text
You can read the formatted text of a cell by using the Text property. The property is read-only.
Syntax
expression.Range.Textexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:B2'); // Read the formatted text of the cell. const text = await range.Text; console.log(text); }
Range.Top
You can obtain the distance from the top edge of row 1 to the top edge of a range by using the Top property.
Syntax
expression.Range.Topexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('B2'); // Obtain the distance from the top edge of row 1 to the top edge of the range. const top = await range.Top; console.log(top); }
Range.VerticalAlignment
You can specify and obtain the vertical alignment of a range by using the VerticalAlignment property. For more information, see the XlVAlign section of the "Table" topic.
Syntax
expression.Range.VerticalAlignmentexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1'); // Specify bottom alignment for the range. range.VerticalAlignment = await app.Enum.XlVAlign.xlVAlignBottom; setTimeout(async () => { // Obtain the alignment after 3,000 milliseconds. const horizontalAlignment = await range.VerticalAlignment; console.log(horizontalAlignment); }, 3000); }
Range.Value
You can write a value in a range by using the Value property.
Syntax
expression.Range.Valueexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1'); // Write a value in the range. range.Value = 'Aliyun'; }
Range.IndentLevel
You can specify the indent level for a range by using the IndentLevel property.
Syntax
expression.Range.IndentLevelexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1'); // Set the indent level of the range to 10 units. range.IndentLevel = 10; }
Range.FormatConditions
You can obtain a collection of all conditional formats in a range by using the FormatConditions property.
Syntax
expression.Range.FormatConditionsexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1'); // Obtain a collection of all conditional formats in the range. const formatConditions = await range.FormatConditions; }
Range.Validation
You can obtain the data validation rules for a range by using the Validation property.
Syntax
expression.Range.Validationexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1'); // Obtain the data validation rules for the range. range.IndentLevel = 10; }
Range.Areas
You can obtain all the selected ranges by using the Areas property.
Only JavaScript SDK V1.1.19 and later support this feature.
Syntax
expression.Range.Areasexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Selection; // Obtain all the selected ranges. const areas = await range.Areas; // The number of selected ranges. const count = await areas.Count; // The first selected range. const area = await areas.Item(1) const address = await area.Address() }
Range.Hyperlinks
You can obtain the Hyperlink objects for a range by using the Hyperlinks property.
Only JavaScript SDK V1.1.19 and later support this feature.
Syntax
expression.Range.Hyperlinksexpression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Selection; // Obtain the Hyperlink objects. const hyperlinks = await range.Hyperlinks; // Obtain a single Hyperlink object. const hyperlink = await hyperlinks.Item(1) }
Range.Value2
You can write a value to a cell by using the Value2 property.
Only JavaScript SDK V1.1.19 and later support this feature.
Syntax
expression.Range.Value2expression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object. const range = await app.Range('A1:B2'); // Write a value to the cell range.Value2 = [['WebOffice', 'WebOffice2'], ['1', '2']]; }