Assigning values to cells in a spreadsheet automatically

vestLA shared this question 2 years ago

Let's say I have a list of numbers L={3,10,8,-4,9} and I want to have them displayed in the cells (1,1), (1,2), ..., (1,5) in a GeoGebra spreadsheet by using a command or some script. If it was in Excel VBA I would write a loop something like the following:

For k=1 To 5


Next k

But I guess there are no loops in GeoGebra, so I don't know how to write a command or script to display the content of the list L automatically.

I hope someone can explain how it can be done in GeoGebra.


Comments (4)


Thank you for referring me to that command. I didn't know about it.

Unfortunately I don't think it applies in my situation. I know the first cell in the column. Let's say it is C2. A variable NP is containing the length of the list. At the moment its value is 5. According to the documentation of this command, it can be used in three different ways. The first way is to write the cellrange in the first entrance. Obviously it could be done in the following way:


but I really cannot know the last Cell C6. I wish this cell could be accessed by its row-column coordinates (3,6), because then I could write it as (3,NP+1). I see no way to tell GeoGebra that it is NP=5 cells after Cell C2!

I also tested the other way of using the FillCell command, by only writing the initial Cell:


that is: omitting C6. But then by default the elements in the list were assigned in the row starting at C2, not in the column!

The third way of using FillCell obviously doesn't apply (no matrix).



attached 2 variants

see script in a

Note: the performanance to delete the columns is critical (ggb6.0)


Thanks Rami. I used your second idea with a transposed matrix and also the idea to delete columns.

I think it is strange, though, that GeoGebra doesn't seem to allow the user to WRITE to the spreadsheet using (row,column) coordinates, when it does allow to READ using these coordinates (see the Cells command). In the current situation one need to make workarounds like what you explain. It could be a suggestion for the developers to implement (row,column)-coordinates when writing to cells as an 4th option for the FillCells command.


© 2023 International GeoGebra Institute