如何使用py-appscript访问数字中的当前表
对于后代,我使用此信息创建的程序将清除当前表中的所有单元格,并将选择返回到单元格A1。我在Automator中使用python Run Shell脚本将其转换为服务,并将其附加到数字。
from appscript import *
Numbers = app('Numbers')
current_table = None
for sheet in Numbers.documents.first.sheets():
for table in sheet.tables():
if table.selection_range():
current_table = table
if current_table:
for cell in current_table.cells():
cell.value.set('')
current_table.selection_range.set(to=current_table.ranges[u'A1'])它被用来清除我用于临时计算的大表中的数字。
发布于 2009-11-08 03:23:33
>>> d = app('Numbers').documents.first() # reference to current top document编辑:似乎没有对当前表的直接单一引用,但看起来您可以通过在当前第一个文档的工作表中搜索具有非空selection_range的表来找到它,因此如下所示:
>>> nu = app('Numbers')
>>> for sheet in nu.documents.first.sheets():
... for table in sheet.tables():
... if table.selection_range():
... print table.name()https://stackoverflow.com/questions/1694060
复制相似问题