2016-06-29 12 views
5

posso impostare il formato di una cella in un foglio di calcolo Numbers utilizzando:Come si imposta il numero di decimali in una cella Numbers utilizzando 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 

Ma come faccio a impostare il numero di cifre decimali della cellula?

risposta

2

Sfortunatamente il dizionario di numeri di AppleScript non supporta l'impostazione t lui decimale, tuttavia è possibile farlo con lo scripting GUI.

Dal GUI scripting dipende fortemente dalla versione del software, questo è per 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 

In una lingua di sistema diversa dall'inglese la stringa letterale Cell potrebbe essere localizzato.

2

Purtroppo non ho Numbers quindi non posso guardare direttamente il dizionario da solo, ma in teoria dovresti avere una proprietà per la cella per i decimali.

This pagina parla di come si modifica manualmente le posizioni decimali nell'applicazione. Quindi sarebbe ragionevole pensare che dovresti essere in grado di fare lo stesso in una sceneggiatura.

Hai provato a fare qualcosa in questo senso ...

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 

Date un'occhiata a ciò che props1 e props2 contenere negli esempi di codice precedenti. Con un po 'di fortuna, uno di questi avrà un riferimento a "cifre decimali" (o qualcosa di simile). Ci scusiamo per eventuali errori nel mio codice, come ho già detto, non ho Numbers per testarne veramente nessuno.

2

Purtroppo ritengo che ciò non sia possibile, almeno non con Numbers v3.6.2. Il dizionario I numeri dimostrano che la proprietà di un 'decimali' non è presente per le cell o range classi

Prendendo lo script e che funzionano con esso:

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 

rivela proprietà:

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

. Nessuno dei quali sembra una proprietà decimali :-(

Problemi correlati