在Excel Javascript API中,我在range类中看到了用于合并和取消合并单元格的方法,但没有看到指示单元格是否被合并以及它包含多少行和列的属性。如果没有一个显式的API来读取这篇文章,有没有人知道一种解决方法-例如。间接检测合并状态还是获取范围的底层xml并对其进行解析?
发布于 2020-04-17 14:42:15
以下是选择一个范围并合并该范围的示例解决方法,然后检查它是否为合并范围:
//get selected range and did merge
var range = context.workbook.getSelectedRange();
range.merge();
await context.sync();
// check whether the range is merged or not
range.load();
await context.sync();
console.log(range["cellCount"]);
const str = range.address;
const colCount = range.columnCount;
const rowCount = range.rowCount;
console.log(colCount);
console.log(rowCount);
if (str) {
const arr = str.split("!");
console.log(arr[1]);
if ((range["cellCount"] > 1 || range["colCount"] > 1 || range["rowCount"] > 1) && arr[1].indexOf(":") == -1) {
console.log("true");
} else {
console.log("false");
}
}
发布于 2020-04-17 15:05:37
很抱歉,我们目前还没有接口(在VBA中,对应的接口是Range.MergeCells
)来检查合并单元的状态。如果您知道合并前的原始range地址,您可以尝试Ginger酱(来自我们团队)的解决方案。
如果您的方案仍然无法解除阻止,我建议您在UserVoice https://officespdev.uservoice.com/forums/224641-feature-requests-and-feedback?category_id=163563上提交您的请求,并对此功能进行投票,我们会将其添加到我们的积压中。
PS。如果你能和我们分享你的场景,那就太好了。因此,我们可以看到如何使用现有API解锁您的场景。
谢谢
https://stackoverflow.com/questions/61273010
复制相似问题