Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

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
Question marked as Best reply

Posted on May 15, 2019 5:36 AM

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

3 replies
Question marked as Best reply

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

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 ID.