How to set the format of range in Numbers by JXA

How to set the format of range in JXA like the following AppleScript code?




tell application "Numbers"
    activate
    tell document 1
        tell active sheet
            tell table 1
                set the format of range "A2:B2" to currency
            end tell
        end tell
    end tell
end tell


I can't find the documentation related to enumeration in JXA. The format property is enumeration.


table.ranges["A2:B2"].format = "currency"


This code will trigger error (invalid format value).

MacBook Pro 13", macOS 10.14

Posted on May 8, 2019 1:10 AM

Reply
3 replies

May 15, 2019 5:36 AM in response to caichicong

Javascript is easier to use than applescript


Not easier to use if the Javascript is as poorly implemented and documented as JXA seems to be!


One can do certain things such as setting values in cells and sorting and so forth, but, as you've discovered, formats don't seem to be recognized.


Better to use AppleScript that works than JXA that is full of "gotchas."


If you're finding AppleScript hard to use with Numbers feel free to post questions.


SG

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to set the format of range in Numbers by JXA

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.