Excel.JavaScriptCustomFunctionReferenceCellValue interface
表示对 JavaScript 自定义函数的引用。
注解
示例
// 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.");
});
属性
| basic |
表示对于具有此值的单元格将返回 |
| basic |
表示对于具有此值的单元格将返回 |
| function |
表示 的类型 |
| id | 表示自定义函数的 ID。 有关详细信息,请参阅 为自定义函数自动生成 JSON 元数据:ID。 |
| namespace | 表示自定义函数使用的命名空间。 有关详细信息,请参阅 清单参考:命名空间。 |
| type | 表示此单元格值的类型。 |
属性详细信息
basicType
表示对于具有此值的单元格将返回 Range.valueTypes 的值。
basicType?: RangeValueType.error | "Error";
属性值
error | "Error"
注解
basicValue
表示对于具有此值的单元格将返回 Range.values 的值。 通过 valuesAsJson 属性访问时,此字符串值与 en-US 区域设置一致。 通过 valuesAsJsonLocal 属性访问时,此字符串值与用户的显示区域设置一致。
basicValue?: "#VALUE!" | string;
属性值
"#VALUE!" | string
注解
functionType
表示 的类型 FunctionCellValue。
functionType: FunctionCellValueType.javaScriptReference | "JavaScriptReference";
属性值
javaScriptReference | "JavaScriptReference"