obtain selected cells from spreadsheet

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

obtain selected cells from spreadsheet

Post by HoWil »

Hello,
I want to obtain the cells I selected in a spreadsheet.

I found that If one selects some cells (for instance C1 to C3) and changes into the python console and inserts:

Code: Select all

App.ActiveDocument.Spreadsheet.cells.Content
one will get something like:

Code: Select all

'<Cells Count="3">\n    <Cell address="C1" content="1" />\n    <Cell address="C2" content="2" />\n    <Cell address="C3" content="3" />\n</Cells>\n'
These cells are also available when one inserts "App.ActiveDocument.Spreadsheet." and presses TAB.
This shows me that there has to be a way to access the requested information, but I cant say how to do it to get it in a structured form like a list (without extracting it from the above given text :? ).
BR,
HoWil
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: obtain selected cells from spreadsheet

Post by HoWil »

Yep.... my model was to simple.... ;)

I had only three cells filled and then selected these three. So "App.ActiveDocument.Spreadsheet.cells.Content" is not related to the ones selected :!: .
Any suggestions how to do something like that or at least how to access a range of Cells (as numpy-array).

I want to use this for two cases:
* for Part-family generation see https://forum.freecadweb.org/viewtopic. ... 91#p156730
* and plotting values in the spreadsheet using the plot-Wb (for running parametrized simulations in FEM-wb and evaluating the results in therms of a plot-figure)

Thanks in advance,
HoWil
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: obtain selected cells from spreadsheet

Post by HoWil »

For all interested, please see here https://forum.freecadweb.org/viewtopic. ... 46#p157579
BR, Howil
Post Reply