如何在 iWork Numbers 中交换表格(转置)中的列和行?

San*_*eef 8 mac iwork iwork-numbers

我想转置一个表(将行交换为列,反之亦然)。如何在 iWork Numbers 中做到这一点。

小智 4

我写了一个简单的 AppleScript 来完成它。

tell application "Numbers"
    activate
    tell the front document
        tell the first sheet
            set original_range to selection range of first table

            set orignal_table to first table
            set number_of_columns to column count of orignal_table
            set number_of_rows to row count of orignal_table
            set trasposed_table to make new table with properties {row count:number_of_columns, column count:number_of_rows}

            repeat with i from 1 to number_of_columns
                repeat with j from 1 to number_of_rows
                    tell orignal_table
                        set original_value to the value of cell i of row j
                    end tell
                    tell trasposed_table
                        set the value of cell j of row i to original_value
                    end tell
                end repeat
            end repeat

        end tell
    end tell
end tell
Run Code Online (Sandbox Code Playgroud)

在这里您可以找到有关它的更多详细信息。

  • 值得一提的是,这个公式采用单元格的“值”,这意味着如果您要转置的单元格中有公式,则只有它们的输出才会被转置。公式不会。 (2认同)