Get Started
Usage API
More information

Api

new Api()

Base class.

Properties

Name Type Description
Sheets Array

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

ActiveSheet ApiWorksheet

Returns an object that represents the active sheet.

Selection ApiRange

Returns an object that represents the selected range.

Methods

Name Description
AddDefName

Adds a new name to a range of cells.

AddSheet

Creates a new worksheet. The new worksheet becomes the active sheet.

CreateBlipFill

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

CreateBullet

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

CreateColorByName

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

CreateColorFromRGB

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

CreateGradientStop

Creates a gradient stop used for different types of gradients.

CreateLinearGradientFill

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

CreateNoFill

Creates no fill and removes the fill from the element.

CreateNumbering

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

CreateParagraph

Creates a new paragraph.

CreatePatternFill

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

CreatePresetColor

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

CreateRadialGradientFill

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

CreateRGBColor

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

CreateRun

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

CreateSchemeColor

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

CreateSolidFill

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

CreateStroke

Creates a stroke adding shadows to the element.

Format

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

GetActiveSheet

Returns an object that represents the active sheet.

GetDefName

Returns an ApiName object by the range name.

GetLocale

Returns the current locale ID.

GetMailMergeData

Returns the mail merge data.

GetRange

Returns an ApiRange object by the range reference.

GetSelection

Returns an object that represents the selected range.

GetSheet

Returns an object that represents a sheet.

GetSheets

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

GetThemesColors

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

Intersect

Returns an ApiRange object that represents the rectangular intersection of two or more ranges. If one or more ranges from a different worksheet are specified, an error will be returned.

RecalculateAllFormulas

Recalculates all formulas in the active workbook.

ReplaceTextSmart

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

Save

Saves changes to the specified document.

SetLocale

Sets a locale to the document.

SetThemeColors

Sets the theme colors to the current spreadsheet.

Example

Copy code
builder.CreateFile("xlsx");
oSheet = Api.AddSheet("New sheet");
oWorksheet = Api.GetSheet("New sheet");
Api.SetLocale("en-CA");
oWorksheet.GetRange("A1").SetValue("Locale: ");
oWorksheet.GetRange("B1").SetValue(Api.GetLocale());
Api.AddDefName("locale", "Sheet1!$A$1:$B$1");
oFill = Api.CreateSolidFill(Api.CreateRGBColor(104, 155, 104));
oStroke = Api.CreateStroke(0, Api.CreateNoFill());
oShape = oWorksheet.AddShape("flowChartOnlineStorage", 120 * 36000, 35 * 36000, oFill, oStroke, 0, 5 * 36000, 0, 10 * 36000);
oDocContent = oShape.GetContent();
oParagraph = oDocContent.GetElement(0);
oParagraph.AddText(" This is an example for base class methods.");
oBullet = Api.CreateNumbering("ArabicParenR", 1);
oParagraph = Api.CreateParagraph();
oParagraph.SetBullet(oBullet);
oParagraph.AddText(" A sheet named 'New sheet' was added.");
oDocContent.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.SetBullet(oBullet);
oParagraph.AddText(" The language of the document was set to English (Canada).");
oDocContent.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.SetBullet(oBullet);
oParagraph.AddText(" A green shape was created with numbered paragraphs in it.");
oDocContent.Push(oParagraph);
builder.SaveFile("xlsx", "Api.xlsx");
builder.CloseFile();

Resulting document