[英]How do I detect merged cells in a range from an Excel Javascript Add-In?
In the Excel Javascript API, I see the methods on the the range class to merge and unmerge cells, but don't see properties that indicate if a cell is merged and how many rows and columns it encompasses. 如果沒有明確的 API 來閱讀此內容,是否有人知道解決方法 - 例如。 間接檢測合並狀態或獲取范圍的底層 xml 並解析它?
這是 select 范圍的示例工作並合並范圍,然后檢查它是否是合並范圍:
//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");
}
}
I am sorry, currently we don't have a API (in VBA, corresponding API is Range.MergeCells
) to check the state of merged cells. 如果您在合並之前知道原始范圍地址,您可以嘗試 Ginger Jiang(來自我們團隊)的解決方法。
如果您的方案仍然無法解除阻止,我建議您在 UserVoice https://officespdev.uservoice.com/forums/224641-feature-requests-and-feedback?category_id=163563上提交您的請求並支持此功能,我們會將其添加到我們的待辦事項中。
PS。 如果您能與我們分享您的場景,那就太好了。 因此,我們可以看到如何使用現有 API 解除對您的場景的阻塞。
謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.