Get Started
Usage API

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.

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.

Methods

Name Description
AddComment

Adds a comment to the range.

Clear

Clears the entire object.

ForEach

The ForEach() method executes a provided function once for each cell

GetAddress

Get cell adress

GetClassType

Get the type of this class.

GetCol

Get the number of the column for the selected cell.

GetColumnWidth

Get columns width value

GetComment

Returns a ApiComment.

GetCount

Get count rows or columns

GetDefName

Returns a ApiName.

GetFillColor

Get the background color for the current cell range

GetFormula

Gets the formula of the first cell in range.

GetHidden

Get hidden value

GetRow

Get the number of the row for the selected cell.

GetRowHeight

Get rows height value

GetRows

Returns a Range object that represents the rows in the specified range.

GetText

Gets the text of the first cell in range.

GetValue

Gets the value of the first cell in range.

GetValue2

Gets the value2 of the first cell in range.

GetWorksheet

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

GetWrapText

Returns whether the words in a cell have been wrapped to fit the cell size.

Merge

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

Select

Selects 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

Sets the width of all 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 hidden value

SetItalic

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

SetNumberFormat

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

SetOffset

Set cell offset

SetRowHeight

Set rows height value

SetStrikeout

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

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

Specifies 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