Posted 14 August 2025, 2:02 pm EST - Updated 14 August 2025, 3:56 pm EST
Hi had some problems when making an activeSheet’s tab visible via a button control. Ideally the control I tried should scroll to the tab that is the active sheet. Problem is we could have 20 sheets of workbook with really large names so its not like I have 3 short named tabs visible all the time.
The following code does NOT work (note: CoPilot acts like getTabStrip is an accessible function: it is not):
//(1):
// I know now getTabStrip is either non-accessible or nonexistent
function changeActiveSheet(sheetName) {
const designer = GC.Spread.Sheets.Designer.findControl(document.getElementById('spreadJsSpreadsheet'));
const spread = designer.getWorkbook();
spread.setActiveSheet(sheetName);
spread.getTabStrip().scrollToSheet(sheetName);// Not attached to workbook; getTabStrip is either non-accessible or a nonexistent function?
}
tryScrollToTab();
}
//(2):
function changeActiveSheet(sheetName) {
const designer = GC.Spread.Sheets.Designer.findControl(document.getElementById('spreadJsSpreadsheet'));
const spread = designer.getWorkbook();
spread.setActiveSheet(sheetName);
let attempts = 0;
const maxAttempts = 10;
const delay = 300; // ms between retries
function tryScrollToTab() {
if (spread.getTabStrip && typeof spread.getTabStrip === "function") {
spread.getTabStrip().scrollToSheet(sheetName); //Again doesn't work; getTabStrip is either non-accessible or nonexistent.
} else if (attempts < maxAttempts) {
attempts++;
setTimeout(tryScrollToTab, delay);
} else {
console.warn("Tab strip still not available after multiple attempts.");
}
}
tryScrollToTab();
}
//(3):
function changeActiveSheet(sheetName) {
const designer = GC.Spread.Sheets.Designer.findControl(document.getElementById('spreadJsSpreadsheet'));
const spread = designer.getWorkbook();
spread.setActiveSheet(sheetName);
setTimeout(() => {
const activeSheet = spread.getActiveSheet();
if (activeSheet) {
spread.setActiveSheet(activeSheet.name()); // Re-setting may trigger tab visibility? Nope.
}
}, 1000);
}
the getTabStrip() function seems like it doesn’t exist or isnt recongnized as part of the workbook. I get errors or warnings like: “1587 EXECPTION THROWN : spread.getTabStrip is not a function”
When I load the workbook some raw data from an HTTP request response (JSON) It seems to work fine:
var designer = GC.Spread.Sheets.Designer.findControl(document.getElementById('spreadJsSpreadsheet'));
var spread = designer.getWorkbook();
//Later after loading the workbook:
//Organize the workbook: set the active sheet name, put in proper order and make active sheet's tab visible.
let newActiveSheetName = scrubSheetName(data[0].reportName); //Grab the name of the new active sheet.
let desiredOrder = getDesiredOrderFromTreeList("reportsTreeList"); //get the order of the sheets, dicatated by the Reports Treelist order.
desiredOrder.forEach((sheetName, index) => { //Order the sheets.
spread.changeSheetPosition(sheetName, index);
});
spread.setActiveSheet(newActiveSheetName); //Set the active sheet.
// spread.getTabStrip().scrollToSheet(newActiveSheetName); // Ensures the active sheet's tab is visible. I know now getTabStrip is either nonaccessible or nonexistent :(
Any ideas?
George