ApiWorksheet

class ApiWorksheet

Description

Class representing a sheet.

Instance Methods

GetVisible(): boolean

Returns the state of sheet visibility.

SetVisible(isVisible)

Sets the state of sheet visibility.

SetActive()

Makes the current sheet active.

GetActiveCell(): ApiRange

Returns an object that represents an active cell.

GetSelection(): ApiRange

Returns an object that represents the selected range.

GetCells(row, col): ApiRange | "null"

Returns the ApiRange that represents all the cells on the worksheet (not just the cells that are currently in use).

GetRows(value): ApiRange | "null"

Returns the ApiRange object that represents all the cells on the rows range.

GetCols(sRange): ApiRange

Returns the ApiRange object that represents all the cells on the columns range.

GetUsedRange(): ApiRange

Returns the ApiRange object that represents the used range on the specified worksheet.

GetName(): string

Returns a sheet name.

SetName(sName)

Sets a name to the current active sheet.

GetIndex(): number

Returns a sheet index.

GetRange(Range1, Range2): ApiRange | "null"

Returns an object that represents the selected range of the current sheet.

GetRangeByNumber(nRow, nCol): ApiRange

Returns an object that represents the selected range of the current sheet using the row/column coordinates for the cell selection.

FormatAsTable(sRange)

Formats the selected range of cells from the current sheet as a table (with the first row formatted as a header).

SetColumnWidth(nColumn, nWidth, bWithotPaddings)

Sets the width of the specified column.

SetRowHeight(nRow, nHeight)

Sets the height of the specified row measured in points.

SetDisplayGridlines(isDisplayed)

Specifies whether the current sheet gridlines must be displayed or not.

SetDisplayHeadings(isDisplayed)

Specifies whether the current sheet row/column headers must be displayed or not.

SetLeftMargin(nPoints)

Sets the left margin of the sheet.

GetLeftMargin(): number

Returns the left margin of the sheet.

SetRightMargin(nPoints)

Sets the right margin of the sheet.

GetRightMargin(): number

Returns the right margin of the sheet.

SetTopMargin(nPoints)

Sets the top margin of the sheet.

GetTopMargin(): number

Returns the top margin of the sheet.

SetBottomMargin(nPoints)

Sets the bottom margin of the sheet.

GetBottomMargin(): number

Returns the bottom margin of the sheet.

SetPageOrientation(sPageOrientation)

Sets the page orientation.

GetPageOrientation(): PageOrientation

Returns the page orientation.

GetPrintHeadings(): boolean

Returns the page PrintHeadings property which specifies whether the current sheet row/column headings must be printed or not.

SetPrintHeadings(bPrint)

Specifies whether the current sheet row/column headers must be printed or not.

GetPrintGridlines(): boolean

Returns the page PrintGridlines property which specifies whether the current sheet gridlines must be printed or not.

SetPrintGridlines(bPrint)

Specifies whether the current sheet gridlines must be printed or not.

GetDefNames(): ApiName[]

Returns an array of ApiName objects.

GetDefName(defName): ApiName | "null"

Returns the ApiName object by the worksheet name.

AddDefName(sName, sRef, isHidden): boolean

Adds a new name to the current worksheet.

GetComments(): ApiComment[]

Returns all comments from the current worksheet.

Delete()

Deletes the current worksheet.

SetHyperlink(sRange, sAddress, subAddress, sScreenTip, sTextToDisplay)

Adds a hyperlink to the specified range.

AddChart(sDataRange, bInRows, sType, nStyleIndex, nExtX, nExtY, nFromCol, nColOffset, nFromRow, nRowOffset): ApiChart

Creates a chart of the specified type from the selected data range of the current sheet.

AddShape(sType, nWidth, nHeight, oFill, oStroke, nFromCol, nColOffset, nFromRow, nRowOffset): ApiShape

Adds a shape to the current sheet with the parameters specified.

AddImage(sImageSrc, nWidth, nHeight, nFromCol, nColOffset, nFromRow, nRowOffset): ApiImage

Adds an image to the current sheet with the parameters specified.

AddWordArt(oTextPr, sText, sTransform, oFill, oStroke, nRotAngle, nWidth, nHeight, nFromCol, nFromRow, nColOffset, nRowOffset): ApiDrawing

Adds a Text Art object to the current sheet with the parameters specified.

AddOleObject(sImageSrc, nWidth, nHeight, sData, sAppId, nFromCol, nColOffset, nFromRow, nRowOffset): ApiOleObject

Adds an OLE object to the current sheet with the parameters specified.

ReplaceCurrentImage(sImageUrl, nWidth, nHeight)

Replaces the current image with a new one.

GetAllDrawings(): ApiDrawing[]

Returns all drawings from the current sheet.

GetAllImages(): ApiImage[]

Returns all images from the current sheet.

GetAllShapes(): ApiShape[]

Returns all shapes from the current sheet.

GetAllCharts(): ApiChart[]

Returns all charts from the current sheet.

GetAllOleObjects(): ApiOleObject[]

Returns all OLE objects from the current sheet.

Move(before, after)

Moves the current sheet to another location in the workbook.

GetPivotByName(name): ApiPivotTable | "null"

Return PivotTable by name.

GetAllPivotTables(): ApiPivotTable[]

Returns all PivotTables on worksheet.

RefreshAllPivots()

Refresh all PivotTables on current worksheet.

GetFreezePanes(): ApiFreezePanes

Returns the freeze panes from the current worksheet.

AddProtectedRange(sTitle, sDataRange): ApiProtectedRange | "null"

Creates a protected range of the specified type from the selected data range of the current sheet.

GetProtectedRange(sTitle): ApiProtectedRange | "null"

Returns a protected range object by its title.

GetAllProtectedRanges(): ApiProtectedRange[] | "null"

Returns all protected ranges from the current worksheet.

Paste(destination)

Pastes the contents of the clipboard to the current sheet.

Instance Properties

Visibleboolean

Returns or sets the state of sheet visibility.

Activenumber

Makes the current sheet active.

ActiveCellApiRange

Returns an object that represents an active cell.

SelectionApiRange

Returns an object that represents the selected range.

CellsApiRange

Returns ApiRange that represents all the cells on the worksheet (not just the cells that are currently in use).

RowsApiRange

Returns ApiRange that represents all the cells of the rows range.

ColsApiRange

Returns ApiRange that represents all the cells of the columns range.

UsedRangeApiRange

Returns ApiRange that represents the used range on the specified worksheet.

Namestring

Returns or sets a name of the active sheet.

Indexnumber

Returns a sheet index.

LeftMarginnumber

Returns or sets the size of the sheet left margin measured in points.

RightMarginnumber

Returns or sets the size of the sheet right margin measured in points.

TopMarginnumber

Returns or sets the size of the sheet top margin measured in points.

BottomMarginnumber

Returns or sets the size of the sheet bottom margin measured in points.

PageOrientationPageOrientation

Returns or sets the page orientation.

PrintHeadingsboolean

Returns or sets the page PrintHeadings property.

PrintGridlinesboolean

Returns or sets the page PrintGridlines property.

Defnames[]

Returns an array of the ApiName objects.

Comments[]

Returns all comments from the current worksheet.

FreezePanesApiFreezePanes

Returns the freeze panes for the current worksheet.

AllProtectedRangesApiProtectedRange[]

Returns all protected ranges from the current worksheet.

PivotTablesApiPivotTable[]

Returns all PivotTables on worksheet.

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).