2016-06-29 21 views
5

tôi có thể thiết lập các định dạng của một ô trong một bảng tính Numbers sử dụng:Làm cách nào để đặt số thập phân trong ô số bằng AppleScript?

tell application "Numbers" 
    activate 
    tell document 1 
     tell active sheet 
      set the selectedTable to ¬ 
       (the first table whose class of selection range is range) 
     end tell 
     tell selectedTable 
      tell column "J" 
       set the format of cell 3 to number 
      end tell 
     end tell 
    end tell 
end tell 

Nhưng làm thế nào để thiết lập số chữ số thập phân của tế bào?

Trả lời

2

Thật không may, từ điển AppleScript của các số không hỗ trợ thiết lập t số thập phân, tuy nhiên bạn có thể làm điều đó với GUI scripting.

Kể từ GUI scripting mạnh phụ thuộc vào phiên bản phần mềm, đây là cho Numbers 3.6.2

tell application "Numbers" 
    activate 
    tell document 1 
     tell active sheet 
      set the selectedTable to ¬ 
       (the first table whose class of selection range is range) 
     end tell 
     tell selectedTable 
      tell column "J" 
       set the format of cell 3 to number 
      end tell 
     end tell 
    end tell 
end tell 

tell application "System Events" 
    tell process "Numbers" 
     tell radio group 1 of window 1 
      if value of radio button "Cell" is 0 then 
       click radio button "Cell" 
       repeat until value of radio button "Cell" is 1 
        delay 0.2 
       end repeat 
      end if 
     end tell 
     tell text field 1 of scroll area 4 of window 1 
      set value of attribute "AXFocused" to true 
      set value to "2" 
      keystroke return 
     end tell 
    end tell 
end tell 

Trong một ngôn ngữ hệ thống khác ngoài tiếng Anh chuỗi chữ Cell có thể được định vị.

2

Thật không may là tôi không có số để tôi không thể tự xem trực tiếp từ điển, nhưng về lý thuyết bạn nên có thuộc tính cho ô cho vị trí thập phân.

This trang nói về cách bạn thay đổi vị trí thập phân theo cách thủ công trong ứng dụng. Vì vậy, nó sẽ đứng lý do mà bạn sẽ có thể làm tương tự như trong một kịch bản.

Các bạn đã thử làm điều gì đó dọc theo những dòng ...

tell application "Numbers" 
    tell document 1 
     tell selectedTable 
      tell column "J" 
       set props1 to properties of cell 3 
       set props2 to properties of format of cell 3 
      end tell 
     end tell 
    end tell 
end tell 

Hãy nhìn vào những gì props1 và props2 chứa trong các ví dụ mã trước. Với bất kỳ may mắn nào, một trong số họ sẽ có một tham chiếu đến "số thập phân" (hoặc một cái gì đó tương tự). Xin lỗi vì bất kỳ lỗi nào trong mã của tôi, như tôi đã đề cập, tôi không có Số để thực sự kiểm tra bất kỳ mã nào.

2

Đáng tiếc tôi tin rằng điều này là không thể, ít nhất là không phải với số v3.6.2. Từ điển Số cho thấy tài sản một 'thập phân' không có mặt cho cell hoặc range lớp

Lấy kịch bản của bạn và chạy với nó:

tell application "Numbers" 
    activate 
    tell document 1 
     tell active sheet 
      set the selectedTable to ¬ 
       (the first table whose class of selection range is range) 
     end tell 
     tell selectedTable 
      tell column "J" 
       set the format of cell 3 to number 
       get properties of cell 3 
      end tell 
     end tell 
    end tell 
end tell 

Tiết lộ thuộc tính:

{vertical alignment:top, row:row "3" of table 1 of sheet 1 of document id "6F1021A0-BA54-47A2-A2DE-15B7E8DAFCED" of application "Numbers", class:cell, font name:"Helvetica", formatted value:"1.2345E+02", background color:missing value, formula:missing value, name:"J3", text wrap:true, text color:{0, 0, 0}, alignment:auto align, column:column "J" of table 1 of sheet 1 of document id "6F1021A0-BA54-47A2-A2DE-15B7E8DAFCED" of application "Numbers", format:scientific, font size:10.0, value:123.45} 

. không ai trong số đó trông giống như một số thập phân bất động sản :-(

Các vấn đề liên quan