We will be migrating from Ask to Discourse on the first week of August, read the details here

Ask Your Question

Writer: how to determine number of rows in a table?

asked 2020-07-19 21:07:33 +0200

ajlittoz gravatar image

LO - Fedora 32

I am presently on a sophisticated table layout viz. page/column break. Author requirements are:

  • some groups of rows are to be considered as an atomic set (no page/column break inside this group)
  • the whole table can be split across pages/columns (but only at predetermined positions)
  • the table heading must be repeated at head of every page/columns

Considering the first requirement, the table can't use the "simple" Text Flow features (allow table break + allow row break).

I thus split the job between:

  • a single "outer table" with a heading row and a "running" row of merged cells (a single cell across the width of the table)
  • as many tables as atomic sets inserted in "running" rows

The outer table takes care of repeating heading and its rows are not allowed to break.

Unfortunately, I got lost in the middle of my experiment and I no longer know for sure how many "running" rows there are in the outer table because, to give the illusion of a single table, "separating paragraphs" (the ones usually following a table) have been suppressed and padding space in the outer table is set to 0. The usual table boundaries are useless due to the complexity of the nested table structure.

I want to check that I have a single nested table per outer row. How can I get the present number of rows in a table?

Would putting the cursor at the end of what I think to be the last cell of a nested table and pressing Alt+Return be a reliable indicator that I am really at end of a row in the "outer table"?

Table>Properties only shows the number of columns.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2020-07-19 21:30:40 +0200

ebot gravatar image

updated 2020-07-19 21:31:20 +0200

I haven't tested it now with page break!, but:

Mark the outer table with Table>Select.

The table area is displayed in the status bar.

In my example A1:E10, means there are 10 rows.

image description

Can you test it in your configuration?

edit flag offensive delete link more


Note: If you want to have the same table header on all pages, wouldn't it be better to put a table with one row and the desired columns in the page header?

ebot gravatar imageebot ( 2020-07-19 21:36:02 +0200 )edit

@ebot: thanks, despite my experience with Writer (and LO in general), I more than often neglect the value of the status toolbar.

The heading can't be sent into the header because there is standard text before and after the table in this "chapter" and the header already contains the chapter title (all over the chapter). Even with fields, you can't change a header for a part of a chapter (tdf#128041).

I started over the table reformatting (from an existing simple table), creating all the needed rows first in the outer table, without erasing the default empty paragraph when I added the nested tables. I then saw a strange behaviour. This empty paragraph became invisible, occupying no space as soon a a table was added in the next row, making the nested tables contiguous! But, if you move the cursor left from the first position in the first ...(more)

ajlittoz gravatar imageajlittoz ( 2020-07-20 08:07:33 +0200 )edit

@ajlittoz: Your decision to use tables in Writer under "extreme conditions" is nevertheless very interesting.

Thanks for the karma, the status bar was just a spontaneous idea.

ebot gravatar imageebot ( 2020-07-20 08:15:19 +0200 )edit

answered 2020-07-19 23:41:19 +0200

Lupp gravatar image

updated 2020-07-20 11:24:35 +0200

TextTables and their implementation look to me ..hmmm... like a mess.
As long as "simple" (= NOT "complex" with split and/or merged cells). they are usable in a sense.

"Sophisticated" tables and tables nested into other tables or frames might better be regarded evil.
I would tend to also avoid tables spanning pages where possible at all. (Repeated header rows cells are not counted and a cell range of such a table often cannot be re-selected by user code...)

To be able to get the number of rows without needing to select them all, and to read the status bar, there is a way by user code, but I don't know one not being "funny" in a sence. The API doesn't even give access to the TextTable inside which a selection (TextTableCursor) was made. Moving the cursor with expand parameter = False should be expected to result in a single cell, but subsequently selecting it, and getting the selection back again, it results in a TextRange. The TextRange now knows about the TextTable ...
Funny enough? (°)

You may play with the attached example which contains some very crude code in Basic.

(°) It seems there once was decided to handle a cell (TextTable or Spreadsheet) as if identical with he text it contains under relevant aspects. This should be expected to imply inconsistencies.
=== Edit 2020-07-20 about 09:25 UTC ===
Concerning (°) again. This still is not implemented for TextTable in AOO. There I therefore don't know any way, not even a funny one, to get a TextTableCursor to tell me the TextTable it was created for. TextTableCursor service is powerless next to not being usable at all.

edit flag offensive delete link more


TextTables and their implementation look to me ..hmmm... like a mess.

I agree 200%

"Sophisticated" tables and tables nested into other tables or frames might better be regarded evil.

I tried to mitigate the evil debating with the author and I lost. Her specifications are not to be discussed, thus the evil structure to try and handle them.

ajlittoz gravatar imageajlittoz ( 2020-07-20 07:45:06 +0200 )edit

I tried to mitigate the evil debating with the author...

The author of what? Are you talking of the specific document you are working on (helping with)?
If not: Was there a public debate? If so: Where can I find it?

Lupp gravatar imageLupp ( 2020-07-20 11:30:59 +0200 )edit

@Lupp: sorry for being so vague. This was the document author. The document is private in the process of revision before publishing. I can't even make public quotation. And "lorem ipsum" it to give an example of the trouble in this particular table would be a very boring and tedious task even if I reduce page size to A6 to have frequent page/column breaks.

ajlittoz gravatar imageajlittoz ( 2020-07-20 11:50:28 +0200 )edit

@ajlittoz: Don't worry. I expected an answer like the one gotten now.
There was a faint idea, however, there might be an interesting discussion somewhere, in the bugtracker e.g.

Lupp gravatar imageLupp ( 2020-07-20 12:53:15 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2020-07-19 21:07:33 +0200

Seen: 139 times

Last updated: Jul 20 '20