I am using a table in a hidden section (in LibreOffice Writer) in order to enter information to be used in the body of the text document. Some of the cells have a bookmark. When I refer to these bookmarks in the body of the text I get the expected value for numbers, dates and times. However, when I refer to a cell containing text, I get the value 0. Is there no way to refer to bookmarked text?
Have you inadvertently enabled Table
>Number Recognition
? This is nice to make computation in tables but Writer tables are primarily intended to contain text.
If it still does not work after disabling number recognition, select the whole table and Table
>Number Format
to force text interpretation.
PS: when posting here, always mention OS name, LO version and save format.
Thanks for your prompt reaction. Number recognition is not on. I have used the number format in every cell. I have attached a file with an example of my problem. Cells in the third column refer to cells of the second column. I have formatted the date cell as a date (and it does not reproduce the value of the cell referred to, but the formatting code). I have formatted the number cell as a number and it works fine. I have formatted the text cell as text, but all I get is 0. What am I doing wrong?
O am using Windows 10 and LO Version: 7.4.1.2 (x64) / LibreOffice Community
Build ID: 3c58a8f3a960df8bc8fd77b461821e42c061c5f0
CPU threads: 16; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: en-GB (en_GB); UI: nl-NL
Calc: CL
Table errors.odt (11 KB)
IMHO, it is far better to always turn on number recognition and enter dates according to the date recognition pattern as defined in the language options.
7/ enters this month’s 7th day.
7/5 enters this years 7th of May (or 5th of July in US context).
7/5/20 enters the 7th of May in 2020 (or 5th of July in US context).
This correct date value can be displayed in any number format you want without the need to type “Thursday, 7th May 2023”
Likewise, you can type 1234 into a cell and get the correct number formatted as $1,234.00 or whatever adequate number format.
In your sample, the date is formatted as Text. I also don’t see any bookmarks that could be referenced
The third column references the second column. The second column has received a formatting code corresponding to the value but not the third column.
Writer has a very limited formula capability in its tables. It is not Calc. Consider these formulas only provide the possibility to compute a grand total or a tax amount, i.e. to do some very simple arithmetic. I emphasise word “arithmetic”. Even a formula like =<B1>
is already implicitly “arithmetic”, expecting a numeric value in <B1>
. If there is text there, it is tentatively converted to number, giving 0 in case of failure.
Writer tables are intended for tabular text: every cell behaves like a sub-document. The only way to copy text from one location to another one is with cross-references which are “universal” (not limited to tables) and more complex than formulas.
Thanks Andreas, Earnest and Ajlittoz for your answers. I have attached a new example because Earnest found my example was incomplete. What I am trying to do is to put some information in a hidden table at the beginning of a template file so that the contents of the resulting file depend on that hidden information. Cross-references are a problem, because if I overwrite the bookmarked text, the bookmark is overwritten too, so the cross-reference becomes invalid. So I thought if the bookmark is on a cell that I don’t overwrite, and this cell refers to another cell that I can overwrite, then this would do the trick. However this doesn’t work, because the date cells display the date format instead of the date in the reference cell, and the text cells display a 0. After reading your replies I am left with the following question: is there a cross-reference method (obviously without bookmarks) that is resilient to overwriting the target of the reference?
Table errors.odt (12.1 KB)
Here are a couple of ways with text and numbers in a section, Text field is simpler.
Table errors2_93353EA.odt (26.2 KB)
PS: I formatted the date in your table as Date DD-MM-YYYY so it works
Thanks EarnestAI! The captions solution is a strike of genius! This way I can edit the variable data as text, which is easier than editing the properties or the variables. Just what I was looking for! Thanks.
No. I just copied (abused) the way formula numbering (type fn
and press F3) uses caption numbering
There are several ways to define “constants” to be used elsewhere in the document.
-
File
>Properties
Description
tab offers “standard” items accessed through Title, Description, Comment and Keyword fields in cross-referenceDocInformation
tab. UseCustom Properties
to define new ones. They are accessed through expandable Custom.
This is very handy because you need not define any invisible artefact to store their definition. In addition, you don’t erase this definition when overwriting it. - variables
Properties don’t work when you want to hide paragraphs depending on some value. You must use variables because the conditional expression can’t reference anything else than variables (by design, there is no workaround).
These variables must be created and initialised in some hidden artefact like your table (with a column showing the name, a second column explaining the role, and the third one containing the definition). When you double-click, you don’t delete the variable definition because this pops up the configuration dialog.
Reminder: variables are a specific category of field.
PS: when posting here, don’t ask for a fix to a solution you’ve devised. It may be like patching in a wrong track. Remember the famous cartoon about a swing where repair technicians obstinate to fix the tree instead of reconsidering the specification where a simple rope+tyre would have done the trick? Always describe the end goal. This makes it easier to understand the purpose and suggest a simple solution.
For information about the tree swing cartoon, see here.