Posted 11 April 2022, 5:15 am EST
Hi Sebastian,
You can perform the tab click by getting the coordinates of the sheet name from the tab strip and performing click operation.
Please find the attached code snippet through which you can get the coordinate of the sheet name from the tab strip:
function getActiveSheetTabRect(spread, sheetIndex) {
var hostID = spread.getHost().id;
var tabStripHost = document.getElementById(hostID + "_tabStrip");
var offset = getOffset(tabStripHost), width = tabStripHost.clientWidth, height = tabStripHost.clientHeight;
var startX, acTabWidth, flag = false, activeSheetIndex = sheetIndex;
for (var x = 0; x < width; x++) {
var hitInfo = spread.hitTest(x + offset.left, height / 2 + offset.top);
var tabStripHitInfo = hitInfo && hitInfo.tabStripHitInfo;
if (tabStripHitInfo && tabStripHitInfo.sheetTab && tabStripHitInfo.sheetTab.sheetIndex !== void 0) {
if (tabStripHitInfo.sheetTab.sheetIndex === activeSheetIndex) {
if (startX === void 0) {
startX = x;
}
flag = true;
} else if (flag) {
acTabWidth = x - startX;
break;
}
} else if (flag) {
acTabWidth = x - startX;
break;
}
}
return { x: startX + offset.left + 5, y: offset.top, width: acTabWidth, height: height - 5 };
}
function getOffset(elem) {
var docElem, win, box = { top: 0, left: 0 }, ownerDocument = elem && elem.ownerDocument;
if (!ownerDocument) {
return;
}
docElem = ownerDocument.documentElement;
if (elem.getBoundingClientRect) {
try {
box = elem.getBoundingClientRect();
}
catch (e) {
}
}
win = ownerDocument.defaultView;
return {
top: box.top + (win.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0),
left: box.left + (win.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0)
};
}
Please let us know if you need further assistance.
Regards
Ankit