Api
The main class of the Spreadsheet API. Use it to get the active workbook, worksheets, ranges, and the current selection, and to add worksheets, defined names, and custom functions.
Properties
| Name | Type | Description |
|---|---|---|
| ActiveSheet | ApiWorksheet | Returns an object that represents the active sheet. |
| AllComments | ApiComment[] | Returns all comments from the current workbook including comments from all worksheets. |
| Comments | ApiComment[] | Returns all comments related to the whole workbook. |
| FreezePanes | FreezePaneType | Returns or sets the type of freeze panes. |
| PivotTables | ApiPivotTable[] | Returns all pivot tables. |
| ReferenceStyle | ReferenceStyle | Returns or sets the reference style. |
| Selection | ApiRange | Returns an object that represents the selected range. |
| Sheets | ApiWorksheet[] | Returns the Sheets collection that represents all the sheets in the active workbook. |
| WorksheetFunction | ApiWorksheetFunction | Returns an object that represents the function list. |
Methods
The following table lists the available methods.
| Method | Returns | Description |
|---|---|---|
| AddComment | ApiComment | null | Returns an array of ApiComment objects. |
| AddCustomFunction | None | Creates a new custom function. |
| AddCustomFunctionLibrary | None | Registers a new custom functions library (see the SetCustomFunctions plugin method). |
| AddDefName | boolean | Adds a new name to a range of cells. |
| AddSheet | ApiWorksheet | Creates a new worksheet. |
| CentimetersToPoints | number | Converts centimeters to points. |
| ClearCustomFunctions | boolean | Clears all custom functions. |
| Color | ApiColor | Creates an ApiColor from a universal input. |
| CreateBlipFill | ApiFill | Creates a blip fill to apply to the object using the selected image as the object background. |
| CreateBullet | ApiBullet | Creates a bullet for a paragraph with the character or symbol specified with the sSymbol parameter. |
| CreateColorByName | ApiColor | Creates a color selecting it from one of the available color presets. |
| CreateColorFromRGB | ApiColor | Creates an RGB color setting the appropriate values for the red, green and blue color components. |
| CreateCustomGeometry | ApiGeometry | Creates a new custom geometry. |
| CreateGradientStop | ApiGradientStop | Creates a gradient stop used for different types of gradients. |
| CreateLinearGradientFill | ApiFill | Creates a linear gradient fill to apply to the object using the selected linear gradient as the object background. |
| CreateNewHistoryPoint | boolean | Creates a new history point. |
| CreateNoFill | ApiFill | Creates no fill and removes the fill from the element. |
| CreateNumbering | ApiBullet | Creates a bullet for a paragraph with the numbering character or symbol specified with the numType parameter. |
| CreateParagraph | ApiParagraph | Creates a new paragraph. |
| CreatePatternFill | ApiFill | Creates a pattern fill to apply to the object using the selected pattern as the object background. |
| CreatePresetColor | ApiPresetColor | Creates a color selecting it from one of the available color presets. |
| CreatePresetGeometry | ApiGeometry | null | Creates a geometry using one of the available preset shapes. |
| CreateRGBColor | ApiRGBColor | Creates an RGB color setting the appropriate values for the red, green and blue color components. |
| CreateRadialGradientFill | ApiFill | Creates a radial gradient fill to apply to the object using the selected radial gradient as the object background. |
| CreateRun | ApiRun | Creates a new smaller text block to be inserted to the current paragraph or table. |
| CreateSchemeColor | ApiSchemeColor | Creates a complex color scheme selecting from one of the available schemes. |
| CreateSolidFill | ApiFill | Creates a solid fill to apply to the object using a selected solid color as the object background. |
| CreateStroke | ApiStroke | Creates a stroke adding shadows to the element. |
| CreateTextPr | ApiTextPr | Creates the empty text properties. |
| EmusToMillimeters | mm | Converts English Metric Units (EMUs) to millimeters. |
| EmusToPoints | number | Converts EMUs (English Metric Units) to points. |
| Format | string | Returns a class formatted according to the instructions contained in the format expression. |
| GetActiveSheet | ApiWorksheet | Returns an object that represents the active sheet. |
| GetActiveWorkbook | ApiWorkbook | Returns an object that represents the active workbook. |
| GetAllComments | ApiComment[] | Returns all comments from the current workbook including comments from all worksheets. |
| GetAllPivotTables | ApiPivotTable[] | Returns all pivot tables. |
| GetCommentById | ApiComment | Returns a comment from the current document by its ID. |
| GetComments | ApiComment[] | Returns all comments related to the whole workbook. |
| GetCore | ApiCore | Returns the core properties interface for the workbook. |
| GetCustomProperties | ApiCustomProperties | Returns the workbook custom properties. |
| GetDefName | ApiName | Returns the ApiName object by the range name. |
| GetDefNames | ApiName[] | Returns an array of all ApiName objects defined in the workbook, across all scopes (workbook-level and sheet-level). |
| GetDocumentInfo | object | Returns the document information: |
| GetFreezePanesType | FreezePaneType | Returns the freeze panes type. |
| GetFullName | string | Returns the full name of the currently opened file. |
| GetLocale | number | Returns the current locale ID. |
| GetMailMergeData | string[][] | Returns the mail merge data. |
| GetPivotByName | ApiPivotTable | null | Returns a pivot table by its name, or null if it does not exist. |
| GetRange | ApiRange | Returns the ApiRange object by the range reference. |
| GetReferenceStyle | ReferenceStyle | Returns the cell reference style. |
| GetSelection | ApiRange | Returns an object that represents the selected range. |
| GetSheet | ApiWorksheet | null | Returns an object that represents a sheet. |
| GetSheets | ApiWorksheet[] | Returns a sheet collection that represents all the sheets in the active workbook. |
| GetThemesColors | string[] | Returns a list of all the available theme colors for the spreadsheet. |
| GetWorksheetFunction | ApiWorksheetFunction | Returns the ApiWorksheetFunction object. |
| HexColor | ApiColor | Creates a color from a HEX string. |
| InchesToPoints | number | Converts inches to points. |
| InsertPivotExistingWorksheet | ApiPivotTable | Inserts the specified pivot table into an existing worksheet. |
| InsertPivotNewWorksheet | ApiPivotTable | Inserts the specified pivot table into a new worksheet. |
| Intersect | ApiRange | null | Returns the ApiRange object that represents the rectangular intersection of two or more ranges. |
| LinesToPoints | number | Converts lines to points (1 line = 12 points). |
| MillimetersToEmus | EMU | Converts millimeters to English Metric Units (EMUs). |
| MillimetersToPixels | number | Converts millimeters to pixels. |
| MillimetersToPoints | number | Converts millimeters to points. |
| PicasToPoints | number | Converts picas to points. |
| PixelsToEmus | number | Converts pixels to EMUs (English Metric Units). |
| PixelsToPoints | number | Converts pixels to points. |
| PointsToCentimeters | number | Converts points to centimeters. |
| PointsToEmus | number | Converts points to EMUs (English Metric Units). |
| PointsToInches | number | Converts points to inches. |
| PointsToLines | number | Converts points to lines (1 line = 12 points). |
| PointsToMillimeters | number | Converts points to millimeters. |
| PointsToPicas | number | Converts points to picas (1 pica = 12 points). |
| PointsToPixels | number | Converts points to pixels. |
| PointsToTwips | number | Converts points to twips. |
| RGB | ApiColor | Creates an RGB color from red, green and blue components. |
| RGBA | ApiColor | Creates an RGBA color from red, green, blue and alpha components. |
| RecalculateAllFormulas | boolean | Recalculates all formulas in the active workbook. |
| RefreshAllPivots | None | Refreshes all pivot tables. |
| RemoveCustomFunction | boolean | Removes a custom function. |
| ReplaceTextSmart | boolean | Replaces each paragraph (or text in cell) in the select with the corresponding text from an array of strings. |
| Save | boolean | Saves changes to the specified document. |
| SetFreezePanesType | None | Sets a type to the freeze panes. |
| SetLocale | boolean | Sets a locale to the document. |
| SetReferenceStyle | None | Sets the cell reference style. |
| SetThemeColors | boolean | Sets the theme colors to the current spreadsheet. |
| ThemeColor | ApiColor | Creates a theme color. |
| TwipsToPoints | number | Converts twips to points. |
| attachEvent | None | Subscribes to the specified event and calls the callback function when the event fires. |
| detachEvent | None | Unsubscribes from the specified event. |