I can set the format of a cell in a Numbers spreadsheet using:
tell application "Numbers"
activate
tell document 1
tell active sheet
set the selectedTable to ¬
(the first table whose class of selection range is range)
end tell
tell selectedTable
tell column "J"
set the format of cell 3 to number
end tell
end tell
end tell
end tell
But how do I set the number of decimal places of the cell?
Unfortunately the AppleScript dictionary of Numbers does not support to set the decimal places, however you can do it with GUI scripting.
Since GUI scripting strongly depends on the software version, this is for Numbers 3.6.2
tell application "Numbers"
activate
tell document 1
tell active sheet
set the selectedTable to ¬
(the first table whose class of selection range is range)
end tell
tell selectedTable
tell column "J"
set the format of cell 3 to number
end tell
end tell
end tell
end tell
tell application "System Events"
tell process "Numbers"
tell radio group 1 of window 1
if value of radio button "Cell" is 0 then
click radio button "Cell"
repeat until value of radio button "Cell" is 1
delay 0.2
end repeat
end if
end tell
tell text field 1 of scroll area 4 of window 1
set value of attribute "AXFocused" to true
set value to "2"
keystroke return
end tell
end tell
end tell
In a system language other than English the literal string Cell
might be localized.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With