Api

class Api

Description

Base class.

Instance Methods

CreateParagraph(): ApiParagraph

Creates a new paragraph.

CreateRun(): ApiRun

Creates a new smaller text block to be inserted to the current paragraph or table.

CreateRGBColor(r, g, b): ApiRGBColor

Creates an RGB color setting the appropriate values for the red, green and blue color components.

CreateSchemeColor(sSchemeColorId): ApiSchemeColor

Creates a complex color scheme selecting from one of the available schemes.

CreatePresetColor(sPresetColor): ApiPresetColor

Creates a color selecting it from one of the available color presets.

CreateSolidFill(oUniColor): ApiFill

Creates a solid fill to apply to the object using a selected solid color as the object background.

CreateLinearGradientFill(aGradientStop, Angle): ApiFill

Creates a linear gradient fill to apply to the object using the selected linear gradient as the object background.

CreateRadialGradientFill(aGradientStop): ApiFill

Creates a radial gradient fill to apply to the object using the selected radial gradient as the object background.

CreatePatternFill(sPatternType, BgColor, FgColor): ApiFill

Creates a pattern fill to apply to the object using the selected pattern as the object background.

CreateBlipFill(sImageUrl, sBlipFillType): ApiFill

Creates a blip fill to apply to the object using the selected image as the object background.

CreateNoFill(): ApiFill

Creates no fill and removes the fill from the element.

CreateStroke(nWidth, oFill): ApiStroke

Creates a stroke adding shadows to the element.

CreateGradientStop(oUniColor, nPos): ApiGradientStop

Creates a gradient stop used for different types of gradients.

CreateBullet(sSymbol): ApiBullet

Creates a bullet for a paragraph with the character or symbol specified with the sSymbol parameter.

ReplaceTextSmart(arrString, sParaTab, sParaNewLine)

Replaces each paragraph (or text in cell) in the select with the corresponding text from an array of strings.

CreateTextPr(): ApiTextPr

Creates the empty text properties.

GetFullName(): string

Returns the full name of the currently opened file.

Format(expression, format): string

Returns a class formatted according to the instructions contained in the format expression.

AddCustomFunction(fCustom)

Creates a new custom function.

AddCustomFunctionLibrary(sName, Func)

Register a new custom functions library (see SetCustomFunctions plugin method).

RemoveCustomFunction(sName): boolean

Removes a custom function.

ClearCustomFunctions(): boolean

Clears all custom functions.

AddSheet(sName)

Creates a new worksheet.

GetSheets(): ApiWorksheet[]

Returns a sheet collection that represents all the sheets in the active workbook.

SetLocale(LCID)

Sets a locale to the document.

GetLocale(): number

Returns the current locale ID.

GetActiveSheet(): ApiWorksheet

Returns an object that represents the active sheet.

GetSheet(nameOrIndex): ApiWorksheet | "null"

Returns an object that represents a sheet.

GetThemesColors(): string[]

Returns a list of all the available theme colors for the spreadsheet.

SetThemeColors(sTheme): boolean

Sets the theme colors to the current spreadsheet.

CreateNewHistoryPoint()

Creates a new history point.

CreateColorFromRGB(r, g, b): ApiColor

Creates an RGB color setting the appropriate values for the red, green and blue color components.

CreateColorByName(sPresetColor): ApiColor

Creates a color selecting it from one of the available color presets.

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

Returns the ApiRange object that represents the rectangular intersection of two or more ranges.

GetSelection(): ApiRange

Returns an object that represents the selected range.

AddDefName(sName, sRef, isHidden): boolean

Adds a new name to a range of cells.

GetDefName(defName): ApiName

Returns the ApiName object by the range name.

Save()

Saves changes to the specified document.

GetRange(sRange): ApiRange

Returns the ApiRange object by the range reference.

GetWorksheetFunction(): ApiWorksheetFunction

Returns the ApiWorksheetFunction object.

GetMailMergeData(nSheet, bWithFormat): string[][]

Returns the mail merge data.

RecalculateAllFormulas(fLogger): boolean

Recalculates all formulas in the active workbook.

InsertPivotExistingWorksheet(dataRef, pivotRef, confirmation): ApiPivotTable

Inserts PivotTable on existing worksheet.

InsertPivotNewWorksheet(dataRef, newSheetName): ApiPivotTable

Inserts PivotTable on new worksheet.

GetPivotByName(name): ApiPivotTable | "null"

Returns PivotTable by name or null.

RefreshAllPivots()

Refreshs all PivotTables.

GetAllPivotTables(): ApiPivotTable[]

Returns all PivotTables.

attachEvent(eventName, callback)

Subscribes to the specified event and calls the callback function when the event fires.

detachEvent(eventName)

Unsubscribes from the specified event.

AddComment(sText, sAuthor): ApiComment | "null"

Returns an array of ApiComment objects.

GetCommentById(sId): ApiComment

Returns a comment from the current document by its ID.

GetComments(): ApiComment[]

Returns all comments related to the whole workbook.

GetAllComments(): ApiComment[]

Returns all comments from the current workbook including comments from all worksheets.

SetFreezePanesType(FreezePaneType)

Sets a type to the freeze panes.

GetFreezePanesType(): FreezePaneType

Returns the freeze panes type.

GetReferenceStyle(): ReferenceStyle

Returns the cell reference style.

SetReferenceStyle(sReferenceStyle)

Sets the cell reference style.

GetDocumentInfo(): object

Returns the document information: Application - the application the document has been created with.

Instance Properties

Sheets[]

Returns the Sheets collection that represents all the sheets in the active workbook.

ActiveSheetApiWorksheet

Returns an object that represents the active sheet.

SelectionApiRange

Returns an object that represents the selected range.

CommentsApiComment[]

Returns all comments related to the whole workbook.

FreezePanesFreezePaneType

Returns or sets the type of freeze panes.

AllCommentsApiComment[]

Returns all comments from the current workbook including comments from all worksheets.

ReferenceStyleReferenceStyle

Returns or sets the reference style.

WorksheetFunctionApiWorksheetFunction

Returns an object that represents the function list.

PivotTablesApiPivotTable[]

Returns all PivotTables.

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).