Get the current worksheet.

let selectedSheet = workbook.getActiveWorksheet(); 

Get the worksheet with that name "Better".

let sheet = workbook.getWorksheet("Better"); 
if (sheet)

Switch to the new worksheet.


Get all the worksheets in the workbook.

let sheets = workbook.getWorksheets(); 

Get a list of all the worksheet names.

let names = ((sheet) => sheet.getName()); 

Get the total number of worksheets in a workbook.

console.log(`Total worksheets inside of this workbook: ${sheets.length}`); 

Set the tab color each worksheet to a random color.

for (let sheet of sheets) { 
  let colorString = `#${Math.random().toString(16).substr(-6)}`;

Delete a worksheet


Add a blank worksheet with the name "Solutions".

let newSheet = workbook.addWorksheet("Solutions"); 

© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext