Is it possible to update the value of cells with individual values without using a repeat loop? For large data sets, updating each value individually is painfully slow.
-- I am trying to do the equivalient of this:
set {a, b, c} to {1, 2, 3}
tell application "Numbers"
tell active sheet of front document
tell table 1
set myRange to range "A1:A3"
-- This works
set value of cells of myRange to "Constant"
-- This tries to update each cell with {1, 2, 3}
-- rather than A1:1, A2:2, A3:3
set myValues to {1, 2, 3}
set value of cells of myRange to myValues
end tell
end tell
end tell
I don’t have numbers, but I use Excel from time to time, so I figure you maybe give the clipboard like five paragraphs, and then assign the clipboard to a range, or the first cell in the range.
set value of first cell of myRange to the clipboard
or
set value of first cell of myRange to (paragraphs of the clipboard)
or
set value of cells of myRange to the clipboard
or
set value of cells of myRange to (paragraphs of the clipboard)
If that doesn’t work, then maybe Yvan’s way is the only way to do it?
Last thing I can think of is to try to assign the contents of the list, to the value of the cells of the range, or just try to assign it directly to the range, and bypass values of cells entirely.
Edit
Maybe the problem is in the formatting of the numbers, I’d also try to format them as a column of csv, that is like {“1”,“2”,“3”}.
No luck.
We can’t set values of a range.
Only cells have a value property.
Every attempts to set the value of a group of cells with a single command end with the error :
“Erreur dans Numbers : Impossible de convertir {1, 2, 3} en type number, date, text, boolean ou missing value.” number -1700 from {1, 2, 3}
It’s not a new behavior. Numbers '09 which was the first version with an AppleScript dictionary already required that value was set cell by cell.
What is new is the fact that we may set the value of a cell to a date. With Numbers '09 we had to set the value to a string using the local date format.
Alas, it’s not perfect. When we execute the instruction :
set value of cell “B3” of table 1 of active sheet of document 1 to date “samedi 17 janvier 2015 14:27:22”
in France, the cell receive the value : samedi 17 janvier 2015 13:27:22
If we want to keep the time component unchanged, we must continue to insert the value as a string.
set value of cell “C3” of table 1 of active sheet of document 1 to “samedi 17 janvier 2015 14:32:27”
really set the cell’s contents to the date-time samedi 17 janvier 2015 14:32:27
Sometimes I’m wondering if Apple engineers are using the applications which they build and deliver.
Yvan KOENIG (VALLAURIS, France) samedi 17 janvier 2015 14:36:02