0

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!

1 Answers1

3

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!

  • May I ask how you figured this out? I can't find much documentation about how to use jxa with numbers and the documentation in the scriptedtior is very limited. – user1716970 Feb 27 '18 at 13:53
  • 2
    I didn't figure this out myself. Like I posted above, someone helped me out. Yes, documentation to use JXA with Numbers is indeed very limited. However, once you figure it out, JavaScript is much much more powerful than AppleScript in extracting/manipulating/transferring data from one document/sheet/table to another. If that's what you need, it's really worth the effort learning JXA. – user7423370 Feb 28 '18 at 14:42
  • Ok, thank you for your answer. I was just thinking about if I should give up on JXA and try my luck with Applescript. But since I think that Applescript is a bit of a pain to use I will try some more with JXA. – user1716970 Mar 01 '18 at 11:19