访问 iWork Numbers 中的单元格属性

发布于 2024-07-12 04:52:39 字数 1021 浏览 5 评论 0原文

我正在尝试访问 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}

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

干杯

伊恩

I'm trying a access the complete reference for a cell in Applescript. So far I've managed to get the cell reference and the table reference using a script like:

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

I can't seem to get the same structure to work for getting the sheet or the document reference. I have tried accessing the properties of the cell and I get something like:

{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}

The column property of a cell therefore seems to include the complete reference but if I access the reference directly through the column property.
Can anyone give me some guidance as to how I get the sheet and document using applescript.

Cheers

Ian

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恋你朝朝暮暮 2024-07-19 04:52:39

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

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

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

Found the solution, fairly simple as long as the code is in the right order:

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

Can use similar code to check for the document number

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文