官方 API 或检查单元格是否是动态数组一部分的方法
Official API or way to check if a cell is part of dynamic array
我正在做一个例子来检查 JavaScript APIs 在动态数组上的行为。
我先在sheet的单元格A1
中输入一个动态数组=MUNIT(3)
。然后,我意识到所有 formulas[0][0]
、formulaR1C1[0][0]
和 formulaLocal[0][0]
都超过范围 A1
returns =MUNIT(3)
。但是,formulas[0][0]
、formulaR1C1[0][0]
和 formulaLocal[0][0]
等其他单元格上的所有 B1
、A2
returns 都是空字符串。
因此,是否有官方的 JavaScript API 或官方的方法来检查像 B1
这样的单元格是否在动态数组的范围内?
PS: 我猜的一种方法是检查单元格的公式是否为空并且它的值不为空,但我希望有更好的方法。
是的,您可以试用我们即将发布的测试版 API,range.hasSpill
and you can also get the parent by range.getSpillParent()
,这是您可以试用的示例代码。
await Excel.run(async (context) => {
// Check the current cell for any spill parents or spilling-to ranges.
const currentRange = context.workbook.getSelectedRange();
currentRange.load("hasSpill");
await context.sync();
if (currentRange.hasSpill)
{
const spillParent = currentRange.getSpillParentOrNullObject();
spillParent.load("address");
await context.sync();
console.log(`The selected cell has a spill parent: ${spillParent.address}`);
}
});
请注意:preview the beta API,您需要在 CDN 上引用 beta 库
https://appsforoffice.microsoft.com/lib/beta/hosted/office.js
我正在做一个例子来检查 JavaScript APIs 在动态数组上的行为。
我先在sheet的单元格A1
中输入一个动态数组=MUNIT(3)
。然后,我意识到所有 formulas[0][0]
、formulaR1C1[0][0]
和 formulaLocal[0][0]
都超过范围 A1
returns =MUNIT(3)
。但是,formulas[0][0]
、formulaR1C1[0][0]
和 formulaLocal[0][0]
等其他单元格上的所有 B1
、A2
returns 都是空字符串。
因此,是否有官方的 JavaScript API 或官方的方法来检查像 B1
这样的单元格是否在动态数组的范围内?
PS: 我猜的一种方法是检查单元格的公式是否为空并且它的值不为空,但我希望有更好的方法。
是的,您可以试用我们即将发布的测试版 API,range.hasSpill
and you can also get the parent by range.getSpillParent()
,这是您可以试用的示例代码。
await Excel.run(async (context) => {
// Check the current cell for any spill parents or spilling-to ranges.
const currentRange = context.workbook.getSelectedRange();
currentRange.load("hasSpill");
await context.sync();
if (currentRange.hasSpill)
{
const spillParent = currentRange.getSpillParentOrNullObject();
spillParent.load("address");
await context.sync();
console.log(`The selected cell has a spill parent: ${spillParent.address}`);
}
});
请注意:preview the beta API,您需要在 CDN 上引用 beta 库 https://appsforoffice.microsoft.com/lib/beta/hosted/office.js