0

VBA と Excel for Mac を何度か試した結果、構文エラーが返されたので、Applescript と Numbers を使用することにしました。在庫内のすべてのアイテムのバーコードを印刷する必要があります。ただし、バーコード印刷ソフトウェアは印刷行のみを認識し、在庫セルの値を考慮しません。行を n 回複製しようとしています。ここで、n = 列 F の値です。さらに、ソース データには、その製品の最初のバリエーションの列 A と B のデータのみが含まれており、追加の行に次のように複製する必要があります。良い。以下のスクリーンショットをご覧になり、ご協力いただけるかどうかお知らせください。ありがとうございました!

ソース データ形式:

ここに画像の説明を入力

望ましい出力:

ここに画像の説明を入力

4

1 に答える 1

1

スクリプトは、アプリケーションのバージョンによって異なります。

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
于 2015-03-11T17:41:05.437 に答える