Skip to main content

COMPLEX

Converts real and imaginary coefficients into a complex number.

Syntax​

expression.COMPLEX(arg1, arg2, arg3);

expression - A variable that represents a ApiWorksheetFunction class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
arg1RequiredApiRange | ApiName | numberThe real coefficient of the complex number.
arg2RequiredApiRange | ApiName | numberThe imaginary coefficient of the complex number.
arg3OptionalApiRange | ApiName | stringThe suffix for the imaginary component of the complex number. It can be either "i" or "j" in lowercase. If it is omitted, the function will assume suffix to be "i".

Returns​

number

Example​

Create a complex number from parts in a spreadsheet.

// What is a complex number made from two values in a spreadsheet?

// Combine regular and imaginary parts to build a complex number in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let func = Api.WorksheetFunction;
worksheet.GetRange("A1").SetValue(func.COMPLEX(-2, 2.5, "i"));