Excel.FunctionCellValueType enum

表示对象的 FunctionCellValue 类型。

注解

API 集:ExcelApi 1.19

示例

// 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.");
});

字段

javaScriptReference = "JavaScriptReference"

对 JavaScript 自定义函数的引用。 有关详细信息,请参阅在 Excel 中创建自定义函数。