1

我正在尝试访问 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 属性似乎包含完整的引用,但如果我直接通过 column 属性访问引用。谁能给我一些关于如何使用applescript获取工作表和文档的指导。

干杯

伊恩

4

1 回答 1

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

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

于 2009-01-18T10:17:21.550 回答