Excel.JavaScriptCustomFunctionReferenceCellValue interface
Represents a reference to a JavaScript custom function.
Remarks
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-function-references.yaml
// Attach a reference to a JavaScript custom function as a method on a math entity.
await Excel.run(async (context) => {
const sheet: Excel.Worksheet = context.workbook.worksheets.getItem("Sample");
const entityRange: Excel.Range = sheet.getRange("A2");
const referenceType: Excel.FunctionCellValueType = Excel.FunctionCellValueType.javaScriptReference;
const customFunctionReference: Excel.JavaScriptCustomFunctionReferenceCellValue = {
type: Excel.CellValueType.function,
functionType: referenceType,
namespace: "CONTOSO",
id: "GET27"
};
// The namespace and ID identify a function; this value doesn't register its implementation.
const mathEntity: Excel.EntityCellValue = {
type: Excel.CellValueType.entity,
text: "Math value",
properties: {
Value: {
type: Excel.CellValueType.double,
basicValue: 10
},
Get27: customFunctionReference
}
};
entityRange.valuesAsJson = [[mathEntity]];
entityRange.format.autofitColumns();
await context.sync();
console.log("Created the Math value entity in Sample!A2. Read the reference to inspect its metadata.");
});
Properties
| basic |
Represents the value that would be returned by |
| basic |
Represents the value that would be returned by |
| function |
Represents the type of |
| id | Represents the ID of the custom function. For more information, see Autogenerate JSON metadata for custom functions: ID. |
| namespace | Represents the namespace used by the custom function. For more information, see Manifest reference: Namespace. |
| type | Represents the type of this cell value. |
Property Details
basicType
Represents the value that would be returned by Range.valueTypes for a cell with this value.
basicType?: RangeValueType.error | "Error";
Property Value
error | "Error"
Remarks
basicValue
Represents the value that would be returned by Range.values for a cell with this value. When accessed through a valuesAsJson property, this string value aligns with the en-US locale. When accessed through a valuesAsJsonLocal property, this string value aligns with the user's display locale.
basicValue?: "#VALUE!" | string;
Property Value
"#VALUE!" | string
Remarks
functionType
Represents the type of FunctionCellValue.
functionType: FunctionCellValueType.javaScriptReference | "JavaScriptReference";
Property Value
javaScriptReference | "JavaScriptReference"
Remarks
id
Represents the ID of the custom function. For more information, see Autogenerate JSON metadata for custom functions: ID.
id: string;
Property Value
string
Remarks
namespace
Represents the namespace used by the custom function. For more information, see Manifest reference: Namespace.
namespace: string;
Property Value
string
Remarks
type
Represents the type of this cell value.
type: CellValueType.function | "Function";
Property Value
function | "Function"