跳到主要内容

DGET

Extracts from a database a single record that matches the conditions you specify.

Syntax

expression.DGET(arg1, arg2, arg3);

expression - A variable that represents a ApiWorksheetFunction class.

Parameters

NameRequired/OptionalData typeDefaultDescription
arg1RequiredApiRange | ApiNameThe range of cells that makes up the list or database. A database is a list of related data.
arg2RequiredApiRange | ApiName | number | stringThe column which is used in the function. Either the label of the column in double quotation marks or a number that represents the column's position in the list.
arg3RequiredApiRange | ApiNameThe range of cells that contains the conditions you specify. The range includes at least one column label and at least one cell below the column label for a condition.

Returns

number

Example

let worksheet = Api.GetActiveSheet();
let func = Api.GetWorksheetFunction();
worksheet.GetRange("A1").SetValue("Name");
worksheet.GetRange("B1").SetValue("Month");
worksheet.GetRange("C1").SetValue("Sales");
worksheet.GetRange("A2").SetValue("Alice");
worksheet.GetRange("B2").SetValue("Jan");
worksheet.GetRange("C2").SetValue(200);
worksheet.GetRange("A3").SetValue("Alice");
worksheet.GetRange("B3").SetValue("Feb");
worksheet.GetRange("C3").SetValue(250);
worksheet.GetRange("E1").SetValue("Name");
worksheet.GetRange("E2").SetValue("Alice");
worksheet.GetRange("F1").SetValue("Month");
worksheet.GetRange("F2").SetValue("Feb");
let range1 = worksheet.GetRange("A1:C3");
let range2 = worksheet.GetRange("E1:F2");
worksheet.GetRange("F4").SetValue(func.DGET(range1, "Sales", range2));