0

我正在尝试在 excel 中构建一个打字稿功能。例如,我想创建一个像“=doThis(A1:B2)”这样的自定义函数并传入一个 Excel.Range。我已经尝试过 Microsoft Garage 的脚本实验室 ( https://github.com/OfficeDev/script-lab ) 和 Yeoman Office 插件 ( https://docs.microsoft.com/en-us/office/dev /add-ins/quickstarts/excel-custom-functions-quickstart?tabs=excel-windows)。

我在脚本实验室遇到的问题是我不知道如何在代码中引用 excel 应用程序(以及工作簿/工作表/范围)实例。所有 FUNCTION 样本都传入原始值类型,如数字或字符串。我想传入一个 Excel 范围或能够在代码中引用 Excel 范围。

例如,基本的示例函数是这样的:

/**
 * Calculates the volume of a sphere.
 * @customfunction
 * @param {number} radius
 * @returns The volume of the sphere.
 */
function sphereVolume(radius) {
  return (Math.pow(radius, 3) * 4 * Math.PI) / 3;
}

这传递了一个数字。我想传递一个 Excel 对象作为参数;或者至少在代码块中引用它。

提前谢谢你的帮助。

4

0 回答 0