mingsai

Numbers Cell Formulas (Sample)

Feb 22nd, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. property functionNames : {"SUM", "AVERAGE", "MIN", "MAX", "COUNT", "PRODUCT"}
  2. property columnCount : 7
  3. property rowCount : 8
  4. property useColumnHeaders : true
  5. property useRowHeaders : true
  6.  
  7. tell application "Numbers"
  8.     activate
  9.     if not (exists document 1) then make new document
  10.     tell document 1
  11.         tell active sheet
  12.             set thisTable to ¬
  13.                 make new table with properties ¬
  14.                     {row count:rowCount, column count:columnCount}
  15.             tell thisTable
  16.                 if useRowHeaders is true then
  17.                     set columnStartIndex to 2
  18.                 else
  19.                     set columnStartIndex to 1
  20.                 end if
  21.                 set x to 1
  22.                 repeat with i from 2 to the columnCount
  23.                     set thisFunction to item x of functionNames
  24.                     tell column i
  25.                         set alignment to center
  26.                         set vertical alignment to center
  27.                         set the value of cell 1 to thisFunction
  28.                         repeat with q from 2 to (rowCount - 1)
  29.                             set the value of cell q to q
  30.                         end repeat
  31.                         set the rangeStart to the name of cell 2
  32.                         set the rangeEnd to the name of cell -2
  33.                         set thisFormula to ¬
  34.                             "=" & thisFunction & "(" & rangeStart & ":" & rangeEnd & ")"
  35.                         set the value of the last cell to thisFormula
  36.                     end tell
  37.                     set x to x + 1
  38.                 end repeat
  39.                 tell the last row
  40.                     set the background color to {0, 0, 0}
  41.                     set the text color to {65535, 65535, 65535}
  42.                 end tell
  43.             end tell
  44.         end tell
  45.     end tell
  46. end tell
Advertisement
Add Comment
Please, Sign In to add comment