Page 1 of 1
How can read the range as a dictionary?
Posted: Fri Jan 17, 2025 4:08 am
by luofeiyu
How can read the range "A1:B4" as a dictionary with oobasic?
Code: Select all
A B
1 start 2024
2 length 10
3 rrr 0.1
4 pgr 0.03
Re: How can read the range as a dictionary?
Posted: Fri Jan 17, 2025 8:28 am
by Hagar Delest
I think you need to tell more.
What is the intent, what are the input and output variables?
Re: How can read the range as a dictionary?
Posted: Fri Jan 17, 2025 11:53 am
by luofeiyu
Create a dictionary such as :
Code: Select all
dict = {"start":2024,"length":10,"rrr":0.1,"pgr":0.03}
I can read the range :
Code: Select all
Dim oSheet as Object
Dim oCell as Object
oSheet = ThisComponent.CurrentController.getActiveSheet()
oCell = oSheet.getCellRangeByName("A1:B4")
How can assign it as a dictionary in oobasic then?
Re: How can read the range as a dictionary?
Posted: Fri Jan 17, 2025 12:14 pm
by Zizi64
Code: Select all
oCell = oSheet.getCellRangeByName("A1:B4")
This is a range but not a single cell. (It is only a difference in the names, but it is better to name a range as oRange.)
Your cellrange is a two dimensional Array. The names are located on the first "column", and the values in the second "column". You can handle this array by usage the x/y dimension values.
Code: Select all
dict = {"start":2024,"length":10,"rrr":0.1,"pgr":0.03}
I do not know what is the "dictionary in the StarBasic, but (maybe) you can set (fill-in) the values of the "dictionary" by usage the Array dimensions
Re: How can read the range as a dictionary?
Posted: Fri Jan 17, 2025 12:18 pm
by Zizi64
Here is some information about the VBA compatible "Collections":
viewtopic.php?p=57761#p57761
Re: How can read the range as a dictionary?
Posted: Fri Jan 17, 2025 8:10 pm
by Lupp
luofeiyu wrote: ↑Fri Jan 17, 2025 4:08 am
... as a dictionary with oobasic?
How do you want to use the term "dictionary" here? I don't see one.
Do you mean a kind of lookup table?
In what way do you want to point AOO(OO.o/LibO) to the specific range?
Re: How can read the range as a dictionary?
Posted: Fri Jan 17, 2025 11:39 pm
by JeJe
Do you mean the ScriptForge.Dictionary service?
https://help.libreoffice.org/latest/en- ... bPAR=BASIC
(I claim the prize if this is the right guess...)
Re: How can read the range as a dictionary?
Posted: Fri Jan 17, 2025 11:52 pm
by JeJe
There's also the enumerable map
viewtopic.php?p=385856#p385856