任意の行列数のtableを準備する
make a table with number of rows and columns which we want
tell application "Numbers" activate make document tell document 1 tell sheet 1 delete every table make table with properties {row count:20, column count:20} -- (1) make table --(2) tell table 2 set column count to 6 set row count to 5 end tell end tell end tell end tell
行列数の指定:その1
(1)だと簡潔に書ける. ただし,rows:10だとエラーになる.おそらくバグ(もしくは嫌がらせ?). したがって,行数10で準備したいときは11行準備して1行削除するなどする.
行列数の指定:その2
(2)でも可.ただし,自動で設定された行,列の初期値と同じ行数,列数をの指定するとエラー.
もとのtableの削除して新たにtableを作る.
- 取り回しをよくするために,新たにtableを作る.
- applescriptでよく使われる
set X to make new Y
を用いて,ターゲットとするdocument,sheet,tableに名前をつける. - ただし,ここではsheetはもとからあるものに使う.
- ついでに,行の高さと列の幅を指定する.
tell application "Numbers" activate set tgtDoc to make document tell tgtDoc set tgtSheet to front sheet tell tgtSheet delete every table set tgtTable to make new table with properties {row count:20, column count:20, header row count:0, header column count:0} tell tgtTable set height of every row to 20 set width of every column to 20 end tell end tell end tell end tell