Dar*_*zer 5 applescript numbers spreadsheet
我可以使用以下方法在Numbers电子表格中设置单元格的格式:
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
Run Code Online (Sandbox Code Playgroud)
但是如何设置单元格的小数位数?
不幸的是,AppleScript 数字字典不支持设置小数位,但是您可以使用 GUI 脚本来完成。
\n\n由于 GUI 脚本强烈依赖于软件版本,因此这是为了Numbers 3.6.2
tell application "Numbers"\n activate\n tell document 1\n tell active sheet\n set the selectedTable to \xc2\xac\n (the first table whose class of selection range is range)\n end tell\n tell selectedTable\n tell column "J"\n set the format of cell 3 to number\n end tell\n end tell\n end tell\nend tell\n\ntell application "System Events"\n tell process "Numbers"\n tell radio group 1 of window 1\n if value of radio button "Cell" is 0 then\n click radio button "Cell"\n repeat until value of radio button "Cell" is 1\n delay 0.2\n end repeat\n end if\n end tell\n tell text field 1 of scroll area 4 of window 1\n set value of attribute "AXFocused" to true\n set value to "2"\n keystroke return\n end tell\n end tell\nend tell\nRun Code Online (Sandbox Code Playgroud)\n\n在英语以外的系统语言中,文字字符串Cell可能会被本地化。