ExcelScript.RangeView interface
RangeView represents a set of visible cells of the parent range.
Remarks
Examples
/**
* This script copies values and formatting from the
* visible range of a table in Sheet1 into Sheet2.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the filtered data from Sheet1.
const currentSheet = workbook.getWorksheet("Sheet1");
const table = currentSheet.getTables()[0];
const visibleTableRange: ExcelScript.RangeView = table.getRange().getVisibleView();
const source = currentSheet.getRanges(visibleTableRange.getCellAddresses().toString());
// Copy the data into the other sheet.
const otherSheet = workbook.getWorksheet("Sheet2");
const otherRangeCorner = otherSheet.getRange("A1");
otherRangeCorner.copyFrom(source, ExcelScript.RangeCopyType.all);
}
Methods
get |
Represents the cell addresses of the |
get |
The number of visible columns. |
get |
Represents the formula in A1-style notation. If a cell has no formula, its value is returned instead. |
get |
Represents the formula in A1-style notation, in the user's language and number-formatting locale. For example, the English "=SUM(A1, 1.5)" formula would become "=SUMME(A1; 1,5)" in German. If a cell has no formula, its value is returned instead. |
get |
Represents the formula in R1C1-style notation. If a cell has no formula, its value is returned instead. |
get |
Returns a value that represents the index of the |
get |
Represents Excel's number format code for the given cell. |
get |
Gets the parent range associated with the current |
get |
The number of visible rows. |
get |
Represents a collection of range views associated with the range. |
get |
Text values of the specified range. The text value will not depend on the cell width. The # sign substitution that happens in Excel UI will not affect the text value returned by the API. |
get |
Represents the raw values of the specified range view. The data returned could be of type string, number, or a boolean. Cells that contain an error will return the error string. |
get |
Represents the type of data of each cell. |
set |
Represents the formula in A1-style notation. If a cell has no formula, its value is returned instead. |
set |
Represents the formula in A1-style notation, in the user's language and number-formatting locale. For example, the English "=SUM(A1, 1.5)" formula would become "=SUMME(A1; 1,5)" in German. If a cell has no formula, its value is returned instead. |
set |
Represents the formula in R1C1-style notation. If a cell has no formula, its value is returned instead. |
set |
Represents Excel's number format code for the given cell. |
set |
Represents the raw values of the specified range view. The data returned could be of type string, number, or a boolean. Cells that contain an error will return the error string. |
Method Details
getCellAddresses()
Represents the cell addresses of the RangeView
.
getCellAddresses(): string[][];
Returns
string[][]
Examples
/**
* This script copies values and formatting from the
* visible range of a table in Sheet1 into Sheet2.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the filtered data from Sheet1.
const currentSheet = workbook.getWorksheet("Sheet1");
const table = currentSheet.getTables()[0];
const visibleTableRange: ExcelScript.RangeView = table.getRange().getVisibleView();
const source = currentSheet.getRanges(visibleTableRange.getCellAddresses().toString());
// Copy the data into the other sheet.
const otherSheet = workbook.getWorksheet("Sheet2");
const otherRangeCorner = otherSheet.getRange("A1");
otherRangeCorner.copyFrom(source, ExcelScript.RangeCopyType.all);
}
getColumnCount()
The number of visible columns.
getColumnCount(): number;
Returns
number
getFormulas()
Represents the formula in A1-style notation. If a cell has no formula, its value is returned instead.
getFormulas(): string[][];
Returns
string[][]
getFormulasLocal()
Represents the formula in A1-style notation, in the user's language and number-formatting locale. For example, the English "=SUM(A1, 1.5)" formula would become "=SUMME(A1; 1,5)" in German. If a cell has no formula, its value is returned instead.
getFormulasLocal(): string[][];
Returns
string[][]
getFormulasR1C1()
Represents the formula in R1C1-style notation. If a cell has no formula, its value is returned instead.
getFormulasR1C1(): string[][];
Returns
string[][]
getIndex()
Returns a value that represents the index of the RangeView
.
getIndex(): number;
Returns
number
getNumberFormat()
Represents Excel's number format code for the given cell.
getNumberFormat(): string[][];
Returns
string[][]
getRange()
Gets the parent range associated with the current RangeView
.
getRange(): Range;
Returns
getRowCount()
The number of visible rows.
getRowCount(): number;
Returns
number
getRows()
Represents a collection of range views associated with the range.
getRows(): RangeView[];
Returns
getText()
Text values of the specified range. The text value will not depend on the cell width. The # sign substitution that happens in Excel UI will not affect the text value returned by the API.
getText(): string[][];
Returns
string[][]
getValues()
Represents the raw values of the specified range view. The data returned could be of type string, number, or a boolean. Cells that contain an error will return the error string.
getValues(): (string | number | boolean)[][];
Returns
(string | number | boolean)[][]
getValueTypes()
Represents the type of data of each cell.
getValueTypes(): RangeValueType[][];
Returns
setFormulas(formulas)
Represents the formula in A1-style notation. If a cell has no formula, its value is returned instead.
setFormulas(formulas: string[][]): void;
Parameters
- formulas
-
string[][]
Returns
void
setFormulasLocal(formulasLocal)
Represents the formula in A1-style notation, in the user's language and number-formatting locale. For example, the English "=SUM(A1, 1.5)" formula would become "=SUMME(A1; 1,5)" in German. If a cell has no formula, its value is returned instead.
setFormulasLocal(formulasLocal: string[][]): void;
Parameters
- formulasLocal
-
string[][]
Returns
void
setFormulasR1C1(formulasR1C1)
Represents the formula in R1C1-style notation. If a cell has no formula, its value is returned instead.
setFormulasR1C1(formulasR1C1: string[][]): void;
Parameters
- formulasR1C1
-
string[][]
Returns
void
setNumberFormat(numberFormat)
Represents Excel's number format code for the given cell.
setNumberFormat(numberFormat: string[][]): void;
Parameters
- numberFormat
-
string[][]
Returns
void
setValues(values)
Represents the raw values of the specified range view. The data returned could be of type string, number, or a boolean. Cells that contain an error will return the error string.
setValues(values: (string | number | boolean)[][]): void;
Parameters
- values
-
(string | number | boolean)[][]
Returns
void
Office Scripts