区域资源类型Range resource type

区域表示一个或多个相邻的单元格,例如单元格、行、列、单元格块等。Range represents a set of one or more contiguous cells such as a cell, a row, a column, block of cells, etc.

方法Methods

方法Method 返回类型Return Type 说明Description
获取区域Get Range 区域Range 读取 range 对象的属性和关系。Read properties and relationships of range object.
更新Update 区域Range 更新 Range 对象。Update Range object.
BoundingrectBoundingrect 区域Range 获取包含指定区域的最小 range 对象。例如,“B2:C5”和“D10:E15”的 GetBoundingRect 为“B2:E16”。Gets the smallest range object that encompasses the given ranges. For example, the GetBoundingRect of "B2:C5" and "D10:E15" is "B2:E16".
单元格Cell 区域Range 根据行和列编号获取包含单个单元格的 range 对象。单元格可以位于父区域外部,只要其保持在工作表网格内即可。返回的单元格位于相对于区域左上角的单元格的位置。Gets the range object containing the single cell based on row and column numbers. The cell can be outside the bounds of its parent range, so long as it's stays within the worksheet grid. The returned cell is located relative to the top left cell of the range.
Column 区域Range 获取范围中包含的列。Gets a column contained in the range.
ColumnsafterColumnsafter workbookRangeViewworkbookRangeView 获取给定范围右侧的一定数量的列。Gets a certain number of columns to the right of the given range.
ColumnsbeforeColumnsbefore workbookRangeViewworkbookRangeView 获取给定范围左侧的一定数量的列。Gets a certain number of columns to the left of the given range.
EntirecolumnEntirecolumn 区域Range 获取表示区域整列的对象。Gets an object that represents the entire column of the range.
EntirerowEntirerow 区域Range 获取表示区域整行的对象。Gets an object that represents the entire row of the range.
IntersectionIntersection 区域Range 获取表示指定区域的矩形交集的 range 对象。Gets the range object that represents the rectangular intersection of the given ranges.
LastcellLastcell 区域Range 获取区域内的最后一个单元格。例如,“B2:D5”的最后一个单元格是“D5”。Gets the last cell within the range. For example, the last cell of "B2:D5" is "D5".
LastcolumnLastcolumn 区域Range 获取区域内的最后一列。例如,“B2:D5”的最后一列是“D2:D5”。Gets the last column within the range. For example, the last column of "B2:D5" is "D2:D5".
LastrowLastrow 区域Range 获取区域内的最后一行。例如,“B2:D5”的最后一行是“B5:D5”。Gets the last row within the range. For example, the last row of "B2:D5" is "B5:D5".
OffsetrangeOffsetrange 区域Range 获取表示与指定区域偏移的区域的对象。返回的区域的尺寸将与该区域匹配。如果强制使生成的区域位于工作表网格的边界之外,则会引发异常。Gets an object which represents a range that's offset from the specified range. The dimension of the returned range will match this range. If the resulting range is forced outside the bounds of the worksheet grid, an exception will be thrown.
Row 区域Range 获取范围中包含的行。Gets a row contained in the range.
RowsaboveRowsabove workbookRangeViewworkbookRangeView 获取给定范围上方的一定数量的行。Gets a certain number of rows above a given range.
RowsbelowRowsbelow workbookRangeViewworkbookRangeView 获取给定范围下方的一定数量的行。Gets a certain number of rows below a given range.
UsedrangeUsedrange 区域Range 返回指定 range 对象的所用区域。Returns the used range of the given range object.
清除Clear NoneNone 清除区域值、格式、填充、边框等。Clear range values, format, fill, border, etc.
删除Delete NoneNone 删除与区域相关的单元格。Deletes the cells associated with the range.
插入Insert 区域Range 将单个单元格或一系列单元格插入到工作表中取代此区域,并移动其他单元格以留出空间。在现在空白的空间返回新的 Range 对象。Inserts a cell or a range of cells into the worksheet in place of this range, and shifts the other cells to make space. Returns a new Range object at the now blank space.
合并Merge NoneNone 将范围单元格合并到工作表的一个区域内。Merge the range cells into one region in the worksheet.
ResizedrangeResizedrange workbookRangeViewworkbookRangeView 获取与当前范围对象类似的范围对象,但其右下角可通过一定数量的行和列进行展开(或合拢)。Gets a range object similar to the current range object, but with its bottom-right corner expanded (or contracted) by some number of rows and columns.
UnmergeUnmerge NoneNone 将范围单元格取消合并为各个单元格。Unmerge the range cells into separate cells.
VisibleviewVisibleview workbookRangeViewworkbookRangeView 获取筛选的范围中的可见范围。Get the range visible from a filtered range.

属性Properties

属性Property 类型Type 说明Description
addressaddress stringstring 表示 A1 样式的区域引用。地址值将包含工作表引用(如 Sheet1!A1:B4)。只读。Represents the range reference in A1-style. Address value will contain the Sheet reference (e.g. Sheet1!A1:B4). Read-only.
addressLocaladdressLocal stringstring 以用户语言表示对指定区域的区域引用。只读。Represents range reference for the specified range in the language of the user. Read-only.
cellCountcellCount intint 区域中的单元格数目。只读。Number of cells in the range. Read-only.
columnCountcolumnCount intint 表示区域中的列总数。只读。Represents the total number of columns in the range. Read-only.
columnHiddencolumnHidden booleanboolean 表示当前区域中的所有列是否隐藏。Represents if all columns of the current range are hidden.
columnIndexcolumnIndex intint 表示区域中第一个单元格的列编号。从零开始编制索引。只读。Represents the column number of the first cell in the range. Zero-indexed. Read-only.
formulasformulas JsonJson 表示采用 A1 表示法的公式。Represents the formula in A1-style notation.
formulasLocalformulasLocal JsonJson 表示采用 A1 样式表示法的公式,使用用户的语言和数字格式区域设置。例如,英语中的公式 "=SUM(A1, 1.5)" 在德语中将变为 "=SUMME(A1; 1,5)"。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.
formulasR1C1formulasR1C1 JsonJson 表示采用 R1C1 样式表示法的公式。Represents the formula in R1C1-style notation.
hiddenhidden booleanboolean 表示当前区域中的所有单元格是否隐藏。只读。Represents if all cells of the current range are hidden. Read-only.
numberFormatnumberFormat JsonJson 表示 Excel 中指定单元格的数字格式代码。Represents Excel's number format code for the given cell.
rowCountrowCount intint 返回区域中的总行数。只读。Returns the total number of rows in the range. Read-only.
rowHiddenrowHidden booleanboolean 表示当前区域中的所有行是否隐藏。Represents if all rows of the current range are hidden.
rowIndexrowIndex intint 返回区域中第一个单元格的行编号。从零开始编制索引。只读。Returns the row number of the first cell in the range. Zero-indexed. Read-only.
texttext JsonJson 指定区域的文本值。文本值与单元格宽度无关。在 Excel UI 中替代 # 符号不会影响 API 返回的文本值。只读。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. Read-only.
valueTypesvalueTypes JsonJson 表示每个单元格的数据类型。Represents the type of data of each cell. Possible values are: , , , , , , . Read-only. 可取值包括:UnknownEmptyStringIntegerDoubleBooleanErrorThe possible values are: Unknown, Empty, String, Integer, Double, Boolean, Error. 只读。Read-only.
valuesvalues JsonJson 表示指定区域的原始值。返回的数据类型可能是字符串、数字或布尔值。包含一个将返回错误字符串的错误的单元格。Represents the raw values of the specified range. The data returned could be of type string, number, or a boolean. Cell that contain an error will return the error string.

关系Relationships

关系Relationship 类型Type 说明Description
formatformat WorkbookRangeFormatWorkbookRangeFormat 返回一个格式对象,其中封装了区域的字体、填充、边框、对齐方式和其他属性。只读。Returns a format object, encapsulating the range's font, fill, borders, alignment, and other properties. Read-only.
sortsort WorkbookRangeSortWorkbookRangeSort 包含当前区域的工作表。只读。The worksheet containing the current range. Read-only.
worksheetworksheet WorkbookWorksheetWorkbookWorksheet 包含当前区域的工作表。只读。The worksheet containing the current range. Read-only.

JSON 表示形式JSON representation

下面是资源的 JSON 表示形式。Here is a JSON representation of the resource.

{
  "address": "string",
  "addressLocal": "string",
  "cellCount": 1024,
  "columnCount": 1024,
  "columnHidden": true,
  "columnIndex": 1024,
  "formulas": "json",
  "formulasLocal": "json",
  "formulasR1C1": "json",
  "hidden": true,
  "numberFormat": "json",
  "rowCount": 1024,
  "rowHidden": true,
  "rowIndex": 1024,
  "text": "json",
  "valueTypes": "string",
  "values": "json"
}