How do I format a cell so that characters such as a leading equal sign are interpreted as text?
Set the number format code for the respective cell to @
in advance.
If you don’t like that, and you don’t expect Calc to recognize the = Something Or Other
as a text constant, you can enter ="= Something Or Other"
; which displays = Something Or Other
.
Formatting to Text to force any subsequent input to literal text is correct, a constant formula expression is unnecessary overhead.
There are points of view. And “correct” is a doubtable term here. It works - within limits. You may prefer it.
If you want to use the cell next time for a formula again you will need to change the setting again e.g. Disadvantage?
Even the @
setting does not allow to enter - - -
as text e.g. (old bug) “such as … equal sign …” were the words in the question.
But probably my comment is unnecessary overhead again.
I’d suppose that not treating ’ before formulas the same way as before numbers is a usability bug. Having seen the ’ before something that could be otherwise translated to a formula should just tell LO to write the rest of the string to the string content, without the ’ itself; and the reverse process should happen when displaying …
Even the @ setting does not allow to enter - - - as text
It does, if you answer the dialog about formula correction with No or hit Escape, but the dialog even showing up (and thus the attempt to compile the input as formula) on a Text formatted cell I’d consider as bug.
Quoting @erAck: “…on a Text formatted cell I’d consider as bug.”
Me too.
But my actual reason to avoid the “@” wherever possible, and in specific sometimes in a case as described in the current question is that it not is a 'Numbers' format code
, but a directive for the process of recognition after editing which is messy anyway. On the other hand the actual needs in case of a campaign to resolve that mess are too manifold to be addressed by an enhancement request.
Please also note my “If you want to use the cell next time for a formula … you will need to change the setting again…”.
Thanks. I tried both the “@” approach (it took me a bit to figure out where I would enter this, in the Format/Cells/Numbers menu) and the ="=" approach. They both did what I wanted to do. It’s too bad that the method is not more obvious to find without having to ask a forum! I was used to using a preceding apostrophe per Excel.
The prefixed apostrophe works for numbers. In this case it isn’t mirrored in the .String
property of the cell and also not in the .Formula
property, but only displayed during edit. In case of a formula preceded by the apostrophe that’s different. Not changed in LibO since V3.3 (the very first version).
Buggy insofar is the behaviour of cells formatted to @
.
Since it sounds like Lupp’s answer was correct, please click on the for that question.
Correction to my previous comment:
Replace “and also not in the .Formula property, but only”
with “but in the .Formula
property and also in the .FormulaLocal
property, and thus”