スクリプトは、アプリケーションのバージョンによって異なります。
Numbers バージョン 3.xのスクリプトは次のとおりです。これを試してください。
tell application "Numbers"
tell table 1 of sheet 1 of document 1
set rc to (row count) - 1
set i to 2 -- start at the second row
set {cA, cB} to {"", ""}
repeat rc times
set tValues to value of cells of row i -- get values of this row
set n_rows to item 6 of tValues -- get value in column F
if item 1 of tValues is not missing value then -- not an empty cell
set {cA, cB} to items 1 thru 2 of tValues -- get values of cell A et B
else
set item 1 of tValues to cA -- put the Title into the empty cell (A) --> new row
set item 2 of tValues to cB -- put the Vendor into the empty cell (B) --> new row
set value of cell 1 of row i to cA -- put the Title into the empty cell (A) --> original row
set value of cell 2 of row i to cB -- put the Vendor into the empty cell (B) --> original row
end if
if n_rows > 1 then
set tc to count tValues
set x to properties of row i
if background color of x is missing value then set background color of x to {0, 0, 0}
repeat (n_rows - 1) times -- add rows
set r to make new row at after row i with properties x
repeat with j from 1 to tc -- insert values
set value of cell j of r to item j of tValues
end repeat
end repeat
set i to i + n_rows -- next row, but skip these new rows
else
set i to i + 1 -- next row
end if
end repeat
end tell
end tell
--
Numbers バージョン 2.xのスクリプトは次のとおりです。これを試してください。
tell application "Numbers"
tell table 1 of sheet 1 of document 1
set rc to (row count) - 1
set i to 2 -- start at the second row
set {cA, cB} to {"", ""}
repeat rc times
set tValues to value of cells of row i -- get values of this row
set n_rows to item 6 of tValues -- get value in column F
if item 1 of tValues is not 0.0 then -- 0.0 equal an empty cell for cells whose format is text
set {cA, cB} to items 1 thru 2 of tValues -- get values of cell A et B
else
set item 1 of tValues to cA -- put the Title into the empty cell (A) --> new row
set item 2 of tValues to cB -- put the Vendor into the empty cell (B) --> new row
set value of cell 1 of row i to cA -- put the Title into the empty cell (A) --> original row
set value of cell 2 of row i to cB -- put the Vendor into the empty cell (B) --> original row
end if
if n_rows > 1 then
set tc to count tValues
set {aa, bg, fs, va, ht, tco, fn, tw} to {alignment, background color, font size, vertical alignment, height, text color, font name, text wrap} of row i
try
bg
on error
set bg to missing value
end try
repeat (n_rows - 1) times -- add rows
add row below row i
set properties of row (i + 1) to {alignment:aa, background color:bg, font size:fs, vertical alignment:va, height:ht, text color:tco, font name:fn, text wrap:tw}
repeat with j from 1 to tc -- insert values
set value of cell j of row (i + 1) to item j of tValues
end repeat
end repeat
set i to i + n_rows -- next row, but skip these new rows
else
set i to i + 1 -- next row
end if
end repeat
end tell
end tell