Spreadsheet convert to string

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
renatorivo
Veteran
Posts: 2611
Joined: Tue Feb 21, 2012 8:07 pm
Location: Torino - Italy

Spreadsheet convert to string

Post by renatorivo »

How to convert a value into a string?
Inside a cell =str() doesn't work.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Spreadsheet convert to string

Post by openBrain »

If your question is to force a cell content to be a string, just use single quote (') as the first character.
In other case please make your question more precise.
renatorivo
Veteran
Posts: 2611
Joined: Tue Feb 21, 2012 8:07 pm
Location: Torino - Italy

Re: Spreadsheet convert to string

Post by renatorivo »

openBrain wrote: Fri Jul 10, 2020 12:40 pm If your question is to force a cell content to be a string, just use single quote (') as the first character.
Yes it is this.

A1=3
In A2 I want 3 as string, can you give an example? Thank you.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Spreadsheet convert to string

Post by openBrain »

Just enter

Code: Select all

'3
renatorivo
Veteran
Posts: 2611
Joined: Tue Feb 21, 2012 8:07 pm
Location: Torino - Italy

Re: Spreadsheet convert to string

Post by renatorivo »

I didn't explain myself well, I want to use (convert) the contents of A1 (float or int) as a string, to concatenate two cells, when one of the two cells is already a string.

=A1 + B1 works only with two values or with two strings, not with one string and one value.
TomB19
Posts: 179
Joined: Wed May 01, 2019 4:58 am

Re: Spreadsheet convert to string

Post by TomB19 »

I think you're asking for dynamic string conversion so you can have a string in one cell and the value of the string in another cell. I'm not aware it can do that. In fact, I'm not aware of any functions callable from the Spreadsheet expression editor.

I'd love to have a couple of functions, like "pi()". I link to a spreadsheet of standard values, for that stuff. It works well enough.

OpenBrain's single quote tip sweetened a couple of my spreadsheets. I was using full quotes as a work around but they were visible.

Thank you, OB. 8-)

Sorry it wasn't more helpful for you, Renatorivo. Perhaps someone smarter than me will be able to solve your problem. 8-)
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Spreadsheet convert to string

Post by openBrain »

renatorivo wrote: Fri Jul 10, 2020 3:41 pm I didn't explain myself well, I want to use (convert) the contents of A1 (float or int) as a string, to concatenate two cells, when one of the two cells is already a string.

=A1 + B1 works only with two values or with two strings, not with one string and one value.
I'm not aware of that being possible ATM. There is a quite big PR pending from @realthunder that is refactoring the expressions. Maybe he included this. I'll try to find the PR.
TomB19 wrote: Fri Jul 10, 2020 4:59 pm I'd love to have a couple of functions, like "pi()". I link to a spreadsheet of standard values, for that stuff. It works well enough.
Pi is implemented. Just use :

Code: Select all

pi
renatorivo
Veteran
Posts: 2611
Joined: Tue Feb 21, 2012 8:07 pm
Location: Torino - Italy

Re: Spreadsheet convert to string

Post by renatorivo »

openBrain wrote: Fri Jul 10, 2020 5:12 pm I'll try to find the PR.
Are you referring to this? https://tracker.freecadweb.org/view.php?id=3460
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Spreadsheet convert to string

Post by openBrain »

renatorivo wrote: Fri Jul 10, 2020 7:25 pm Are you referring to this? https://tracker.freecadweb.org/view.php?id=3460
It's wider than just a single ticket. ;)
https://forum.freecadweb.org/viewtopic.php?f=17&t=43412
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: Spreadsheet convert to string

Post by TheMarkster »

A workaround:

Right click in property view, enable show all checkbox.
Right click again in property view, add property of type App::PropertyString. Set this new string property to cell A1 using expressions. Be sure to uncheck the option to prefix group name.
Snip macro screenshot-9ad942.png
Snip macro screenshot-9ad942.png (13.5 KiB) Viewed 1318 times
In the spreadsheet cell refer to the new string property by its name you gave to it (in my case I called it converter).
Snip macro screenshot-c887bc.png
Snip macro screenshot-c887bc.png (95.46 KiB) Viewed 1318 times
Attachments
converter.FCStd
(5.78 KiB) Downloaded 75 times
Post Reply