Update value of range of cells in Numbers

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 tried to do that several times.

The only way which I found is to use GUI Scripting to paste the values separated by TABs and/or RETURNs.

Of course, if somebody found an other answer I would be glad to read it.

Yvan KOENIG (VALLAURIS, France) vendredi 16 janvier 2015 19:00:44

Hi Yvan,

I just finished doing that! I was hoping that I was missing something.

Hello.

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?

No luck.

Hello.

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