Get Started
Usage API

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 selection range.

Methods

Name Description
AddDefName

Defines a new name for a range of cells.

AddSheet

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

CreateBlipFill

Create a blip fill which allows to fill the object using a selected image as the object background.

CreateBullet

Create a bullet for a paragraph with the character or symbol specified with the sBullet parameter.

CreateColorByName

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

CreateColorFromRGB

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

CreateGradientStop

Create a gradient stop used for different types of gradients.

CreateLinearGradientFill

Create a linear gradient fill which allows to fill the object using a selected linear gradient as the object background.

CreateNoFill

Create no fill and remove the fill from the element.

CreateNumbering

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

CreateParagraph

Create a new paragraph.

CreatePatternFill

Create a pattern fill which allows to fill the object using a selected pattern as the object background.

CreatePresetColor

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

CreateRadialGradientFill

Create a radial gradient fill which allows to fill the object using a selected radial gradient as the object background.

CreateRGBColor

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

CreateRun

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

CreateSchemeColor

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

CreateSolidFill

Create a solid fill which allows to fill the object using a selected solid color as the object background.

CreateStroke

Create a stroke adding shadows to the element.

Format

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

GetActiveSheet

Get the object that represents the active sheet.

GetDefName

Returns a ApiName.

GetLocale

Returns current locale id.

GetMailMergeData

Get mail merge data.

GetRange

Returns an ApiRange

GetSelection

Returns an object that represents the selection range

GetSheet

Returns an object that represents the sheet

GetSheets

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

GetThemesColors

Get the list of all available theme colors for the spreadsheet.

Intersect

Returns a 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.

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

Set locale for document.

SetThemeColors

Set 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.GetDocContent();
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