applescriptjavascript-automationapple-numbers

JXA: how to make a new sheet in a document in Numbers.app


I'm using JXA to automate a process using Numbers app. What is the syntax to create a new sheet in an existing document?

var Numbers = Application('Numbers');
Numbers.documents[0].Sheet()...

The AppleScript equivalent would be:

tell application "Numbers"
    tell document 1
        set theSheet to make new sheet with properties {name:sheetName}
    end tell
end tell

Thank you!


Solution

  • With the help of someone special, here is the answer:

    var Numbers = Application('Numbers');
    var newSheet = Numbers.Sheet({name: 'sheetName'});
    Numbers.documents[0].sheets.push(newSheet);
    

    Thank you!