访问iWork Numbers中的单元属性

时间:2009-01-17 23:58:01

标签: applescript iwork

我正在尝试访问Applescript中单元格的完整参考。到目前为止,我已经设法使用如下脚本获取单元格引用和表引用:

tell application "Numbers"
tell document 1
repeat with i from 1 to count of sheets
tell sheet i
repeat with j from 1 to count of tables
tell table j
try
set currentCell to the first cell of the selection range
return name of currentCell
end try
end tell
end repeat
end tell
end repeat
end tell
end tell

我似乎无法获得相同的结构来获取工作表或文档参考。我试过访问单元格的属性,我得到类似的东西:

{column:column "A" of table "Table 1" of sheet "Sheet 1" of document "Untitled" of
 application "Numbers", alignment:center, value:0.0, background color:{59111, 59111, 
59111}, text color:{0, 0, 0}, font size:10.0, vertical alignment:top, name:"A1",
 class:cell, font name:"HelveticaNeue", format:automatic, row:row "1" of table "Table
 1" of sheet "Sheet 1" of document "Untitled" of application "Numbers", text 
wrap:true}

因此,单元格的列属性似乎包含完整的引用,但是如果我直接通过column属性访问引用。 任何人都可以给我一些关于如何使用applescript获取工作表和文档的指导。

干杯

伊恩

1 个答案:

答案 0 :(得分:1)

只要代码的顺序正确,找到解决方案就相当简单了:

tell application "Numbers"
tell document 1
    repeat with i from 1 to count of sheets
        tell sheet i
            repeat with j from 1 to count of tables
                try
                    tell table j
                        set currentCell to the first cell of the selection range
                        set therow to row of currentCell
                        set sheetNumber to i
                    end tell
                end try
            end repeat
        end tell
    end repeat
    return name of sheet sheetNumber
end tell
end tell

可以使用类似的代码来检查文档编号