Ask Your Question
0

How to assign calc 2d named range to python variable - solved

asked 2019-03-11 17:29:19 +0200

bdika gravatar image

updated 2019-03-24 17:35:33 +0200

I can't seem to find a simple answer to the question. I have this successfully working in Basic:

NamedRange = ThisComponent.NamedRanges.getByName("transactions_detail")

RefCells = NamedRange.getReferredCells()

Set MainRange = RefCells.getDataArray()

Then I iterate over MainRange and pull out the rows I am interested in.

Can I do something similar in a python macro? Can I assign a 2d named range to a python variable or do I have to iterate over the range to assign the individual cells?

I am new to python but hope to convert my iteration intensive macro function to python in hopes of making it faster.

Any help would be much appreciated.

Thanks.

(Slightly edited for better readability by @Lupp )

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2019-03-11 23:59:09 +0200

karolus gravatar image

updated 2019-03-12 08:53:43 +0200

do

 doc = XSCRIPTCONTEXT.getDcument()
 NamedRange = doc.NamedRanges["transactions_detail"]
 RefCells = NamedRange.getReferredCells()

 Data = RefCells.getDataArray()
 #calc cast **DataArray** to  nestet tuple of Rows
 #with inner tuple's of Columns for each Row.
 for row in Data:
     …
edit flag offensive delete link more

Comments

thanks karolus

bdika gravatar imagebdika ( 2019-03-24 17:36:18 +0200 )edit

Please, if the answer solves the question click ✔.

m.a.riosv gravatar imagem.a.riosv ( 2019-03-24 22:04:27 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-03-11 17:29:19 +0200

Seen: 81 times

Last updated: Mar 24