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


8

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

Answers:


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

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


2
值得一提的是,此公式采用了单元格的value含义,即如果要转置的单元格中有公式,则只会转置其输出。公式不会。
Nick Q.

3

那些使用最新版本的Numbers的用户可以使用“表格”菜单下的“转置行和列”选项,如在StackExchange上的此答案所示。下图也从该答案中毫不客气地“借用”,以方便参考。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.