문제

현재 숫자로 현재 테이블에 액세스하는 방법 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'])

임시 계산에 사용한 큰 숫자 테이블을 지우는 데 사용되었습니다.

도움이 되었습니까?

해결책

>>> d = app('Numbers').documents.first()  # reference to current top document

편집 : 현재 테이블에 대한 간단한 단일 참조가없는 것 같지만 Null Selection_Range가없는 테이블의 현재 첫 번째 문서의 시트를 검색하여 찾을 수있는 것처럼 보입니다.

>>> nu = app('Numbers')
>>> for sheet in nu.documents.first.sheets():
...   for table in sheet.tables():
...     if table.selection_range():
...        print table.name()
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top