Get Started
Usage API
More information

ApiRange

new ApiRange()

Class representing a range.

Properties

Name Type Description
Row number

Returns the row number for the selected cell.

Col number

Returns the column number for the selected cell.

Rows ApiRange

Returns the ApiRange object that represents the rows of the specified range.

Cols ApiRange

Returns the ApiRange object that represents the columns of the specified range.

Count number

Returns the rows or columns count.

Value string

Returns the value from the first cell of the specified range or sets it to this cell.

Formula string

Returns the formula from the first cell of the specified range or sets it to this cell.

Value2 string

Returns the value2 (value without format) from the first cell of the specified range or sets it to this cell.

Text string

Returns the text from the first cell of the specified range or sets it to this cell.

FontColor ApiColor

Sets the text color to the current cell range with the previously created color object.

Hidden bool

Returns or sets the value hiding property.

ColumnWidth number

Returns or sets the width of all the columns in the specified range measured in points.

Width number

Returns a value that represents the range width measured in points.

RowHeight number

Returns or sets the height of the first row in the specified range measured in points.

Height number

Returns a value that represents the range height measured in points.

FontSize number

Sets the font size to the characters of the current cell range.

FontName string

Sets the specified font family as the font name for the current cell range.

AlignVertical 'center' | 'bottom' | 'top' | 'distributed' | 'justify'

Sets the text vertical alignment to the current cell range.

AlignHorizontal 'left' | 'right' | 'center' | 'justify'

Sets the text horizontal alignment to the current cell range.

Bold bool

Sets the bold property to the text characters from the current cell or cell range.

Underline 'none' | 'single' | 'singleAccounting' | 'double' | 'doubleAccounting'

Sets the type of underline applied to the font.

Strikeout bool

Sets a value that indicates whether the contents of the current cell or cell range are displayed struck through.

FillColor ApiColor | 'No Fill'

Returns or sets the background color of the current cell range.

NumberFormat string

Sets a value that represents the format code for the object.

MergeArea ApiRange

Returns the cell or cell range from the merge area.

Worksheet ApiWorksheet

Returns the ApiWorksheet object that represents the worksheet containing the specified range.

DefName ApiName

Returns the ApiName object.

Comments ApiComment | null

Returns the ApiComment collection that represents all the comments from the specified worksheet.

Orientation 'xlDownward' | 'xlHorizontal' | 'xlUpward' | 'xlVertical'

Sets an angle to the current cell range.

Methods

Name Description
AddComment

Add a comment to the range.

Clear

Clear the entire object.

End

Returns a Range object that represents the end in the specified direction in the specified range.

ForEach

Execute a provided function once for each cell.

GetAddress

Get cell address.

GetCells

Returns a Range object that represents all the cells in the specified range or a specified cell.

GetClassType

Get the type of this class.

GetCol

Get the column number for the selected cell.

GetCols

Returns a Range object that represents all the cells on the columns range.

GetColumnWidth

Get columns width value.

GetComment

Return an ApiComment.

GetCount

Get rows or columns count.

GetDefName

Return an ApiName.

GetFillColor

Get the background color for the current cell range.

GetFormula

Get the formula of the first cell in range.

GetHidden

Get the value hiding property.

GetOrientation

Returns the range angle.

GetRow

Get the row number for the selected cell.

GetRowHeight

Get row height value.

GetRows

Return a Range object that represents the rows in the specified range. If the specified row is outside the Range object, a new Range will be returned that represents the cells between the columns of the original range in the specified row.

GetText

Get the text of the first cell in range.

GetValue

Get the value of the first cell in range.

GetValue2

Get the Value2 property (value without format) of the first cell in range.

GetWorksheet

Return a Worksheet object that represents the worksheet containing the specified range. Read-only.

GetWrapText

Return the information about the wrapping cell style.

Merge

Merge the selected cell range into a single cell or a cell row.

Select

Select the object.

SetAlignHorizontal

Set the horizontal alignment of the text in the current cell range.

SetAlignVertical

Set the vertical alignment of the text in the current cell range.

SetBold

Set the bold property to the text characters in the current cell or cell range.

SetBorders

Set the border to the cell / cell range with the parameters specified.

SetColumnWidth

Set the width of all the columns in the specified range. One unit of column width is equal to the width of one character in the Normal style. For proportional fonts, the width of the character 0 (zero) is used.

SetFillColor

Set the background color for the current cell range with the previously created color object. Set 'No Fill' when previously created color object is null.

SetFontColor

Set the text color for the current cell range with the previously created color object.

SetFontName

Set the specified font family as the font name for the current cell range.

SetFontSize

Set the font size for the characters of the current cell range.

SetHidden

Set the value hiding property.

SetItalic

Set the italic property to the text characters in the current cell or cell range.

SetNumberFormat

Specify whether the number in the cell should be treated like number, currency, date, time, etc. or just like text.

SetOffset

Set cell offset

SetOrientation

Sets an angle to the current cell range.

SetRowHeight

Set row height value.

SetStrikeout

Specify that the contents of the cell / cell range are displayed with a single horizontal line through the center of the contents.

SetUnderline

Specify that the contents of this cell / cell range are displayed along with a line appearing directly below the character.

SetValue

Set the value for the current cell or a cell range.

SetWrap

Specify whether the words in the cell must be wrapped to fit the cell size or not.

UnMerge

Split the selected merged cell range into single cells.

Example

Copy code
builder.CreateFile("xlsx");
oWorksheet = Api.GetActiveSheet();
oWorksheet.GetRange("B1").SetValue("2");
oWorksheet.GetRange("B2").SetValue("2");
oWorksheet.GetRange("A3").SetValue("2x2=");
oWorksheet.GetRange("B3").SetValue("=B1*B2");
builder.SaveFile("xlsx", "ApiRange.xlsx");
builder.CloseFile();

Resulting document