Automatic table cell size in Writer

2 replies [Last post]
LRN
Offline
Last seen: 1 week 2 days ago
Title:
Joined: 19 May 2016
Posts: 2
I’m creating a template .odt document with a table, then i’m filling that table with data. I can’t know in advance how long a particular piece of data will be (i have good estimates for some cells, bot not the other).

I want a cell of the table to either have its height increased (and wrap the contents into multiple lines, even if it contains a single word, which it will have to break into two half-words with no hyphen) or have its width increased. Height is preferable (as table can’t really grow any wider than it already is).

If LibreOffice doesn’t have any mechanisms for doing this, i will accept a way to do it programmatically, but all i have is xml contents of the document.

P.S. To be clear, i’m filling the table by unzipping the .odt file and editing contents.xml directly. I.e. i’m not interacting with LO at that point.

oweng
oweng's picture
Offline
Last seen: 5 days 10 hours ago
Title: ==Moderator==
Joined: 26 Jan 2012
Posts: 3281
default behaviour / test?
LRN wrote:
I want a cell of the table to either have its height increased (and wrap the contents into multiple lines, even if it contains a single word, which it will have to break into two half-words with no hyphen)
Apart from the word breaking aspect I would think this the default behaviour. The word breaking aspect likely requires an example as I am not sure I understand e.g., “Word” set in 12 pt is unlikely to be hyphenated once the cell width is greater than the string length, which in this case would be ~10 mm.

LRN wrote:
To be clear, i’m filling the table by unzipping the .odt file and editing contents.xml directly. I.e. i’m not interacting with LO at that point.
This is the key aspect. Visual adjustment (rendering) is calculated upon document open event. Have you conducted any tests? What are the results / issues?

LRN
Offline
Last seen: 1 week 2 days ago
Title:
Joined: 19 May 2016
Posts: 2
Never mind, i’m just not very
Never mind, i’m just not very observant. More rigorous digging revealed that one can rightclick on a table row, pick “Size->Row Height…” from the context menu, then enable the “Fit to size” checkbox. After i did that, rows started to grow vertically (instead of showing a red triangle indicating that cell contents don’t fit into the cell completely). This handles the text. For numbers, i think i can live with defining a number format with an explicit number of digits (including digits after the decimal point) and pre-fitting the cell size of the template to allow that many digits.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.